Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
if you ever import posts from facebook, and want the times from their open graph feeds to work as Drupal "published times" then you need to first convert the string to a time. Luckily that's pretty easy in PHP, so the plugin was super simple to write.
unfortunately i don't know how to roll a new patch... sorry!
// $Id: strtotime.inc,v 1.1.2.4 2011/02/01 02:33:13 twistor Exp $
$plugin = array(
'form' => 'feeds_tamper_strtotime_form',
'callback' => 'feeds_tamper_strtotime_callback',
'description' => 'feeds_tamper_strtotime_description',
'machine_name' => 'feeds_tamper_strtotime_machine_name',
'name' => 'Convert a string into a Unix Timestamp',
'multi' => 'loop',
'category' => 'TIME',
);
function feeds_tamper_strtotime_form($importer, $element_key, $settings) {
$form = array();
$form['html'] = array(
'#markup' => t('This will take a string containing an English date format and convert it into a Unix Timestamp.')
);
return $form;
}
function feeds_tamper_strtotime_description($settings) {
return 'Convert a string to a timestamp';
}
function feeds_tamper_strtotime_machine_name($settings) {
return 'strtotime';
}
function feeds_tamper_strtotime_callback($source, $item_key, $element_key, &$field, $settings) {
$field = strtotime($field);
}
Comment | File | Size | Author |
---|---|---|---|
#1 | strtotime.patch | 1.19 KB | Bartezz |
Comments
Comment #1
Bartezz CreditAttribution: Bartezz commentedThanx! Works great solving pubDate (1970) issues!
Patch created...
Cheers
Comment #2
anschauung CreditAttribution: anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #3
anschauung CreditAttribution: anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #4
anschauung CreditAttribution: anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #5
anschauung CreditAttribution: anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #6
timoguic CreditAttribution: timoguic commentedThanks - very useful piece of code!
Comment #7
thedavidmeister CreditAttribution: thedavidmeister commentedheh, no worries. I really didn't do much beyond a "find and replace" on one of the provided plugins that is equally as simple.
Comment #8
muschpusch CreditAttribution: muschpusch commentedthis is simple but really nice! Please commit! By the way it works for D7 too....
Comment #9
twistor CreditAttribution: twistor commentedCommitted. Thanks!
http://drupalcode.org/project/feeds_tamper.git/commit/ad1a66f
Comment #11
StephenOTT CreditAttribution: StephenOTT commentedWhat are the accepted date styles?
Comment #12
StephenOTT CreditAttribution: StephenOTT commentedhttp://php.net/manual/en/function.strtotime.php