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);
}
CommentFileSizeAuthor
#1 strtotime.patch1.19 KBBartezz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bartezz’s picture

FileSize
1.19 KB

Thanx! Works great solving pubDate (1970) issues!
Patch created...

Cheers

anschauung’s picture

This plugin worked perfectly for me -- thanks for putting it together!

anschauung’s picture

This plugin worked perfectly for me -- thanks for putting it together!

anschauung’s picture

This plugin worked perfectly for me -- thanks for putting it together!

anschauung’s picture

This plugin worked perfectly for me -- thanks for putting it together!

timoguic’s picture

Thanks - very useful piece of code!

thedavidmeister’s picture

heh, no worries. I really didn't do much beyond a "find and replace" on one of the provided plugins that is equally as simple.

muschpusch’s picture

Status: Needs review » Reviewed & tested by the community

this is simple but really nice! Please commit! By the way it works for D7 too....

twistor’s picture

Assigned: Unassigned » twistor
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

StephenOTT’s picture

What are the accepted date styles?

StephenOTT’s picture