public static function MigrationBase::timestamp in Migrate 7.2
Same name and namespace in other branches
- 6.2 includes/base.inc \MigrationBase::timestamp()
Convert an incoming string (which may be a UNIX timestamp, or an arbitrarily-formatted date/time string) to a UNIX timestamp.
Parameters
string $value: The time string to convert.
string $timezone: Optional timezone for the time string. NULL to leave the timezone unset.
Return value
string The UNIX timestamp.
4 calls to MigrationBase::timestamp()
- MigrateDestinationComment::import in plugins/
destinations/ comment.inc - Import a single comment.
- MigrateDestinationFile::import in plugins/
destinations/ file.inc - Import a single file record.
- MigrateDestinationNode::import in plugins/
destinations/ node.inc - Import a single node.
- MigrateDestinationUser::import in plugins/
destinations/ user.inc - Import a single user.
File
- includes/
base.inc, line 1396 - Defines the base class for migration processes.
Class
- MigrationBase
- The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…
Code
public static function timestamp($value, $timezone = NULL) {
// Does it look like it's already a timestamp? Just return it
if (is_numeric($value)) {
return $value;
}
// Default empty values to now
if (empty($value)) {
return time();
}
if (isset($timezone)) {
$timezone = new DateTimeZone($timezone);
}
$date = new DateTime($value, $timezone);
$time = $date
->format('U');
if ($time == FALSE) {
// Handles form YYYY-MM-DD HH:MM:SS.garbage
if (drupal_strlen($value) > 19) {
$time = strtotime(drupal_substr($value, 0, 19));
}
}
return $time;
}