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);
}
Comments
Comment #1
bartezz commentedThanx! Works great solving pubDate (1970) issues!
Patch created...
Cheers
Comment #2
anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #3
anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #4
anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #5
anschauung commentedThis plugin worked perfectly for me -- thanks for putting it together!
Comment #6
timoguic commentedThanks - very useful piece of code!
Comment #7
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 commentedthis is simple but really nice! Please commit! By the way it works for D7 too....
Comment #9
twistor commentedCommitted. Thanks!
http://drupalcode.org/project/feeds_tamper.git/commit/ad1a66f
Comment #11
StephenOTT commentedWhat are the accepted date styles?
Comment #12
StephenOTT commentedhttp://php.net/manual/en/function.strtotime.php