You are here

function socialcalc_import_date in Sheetnode 5

Same name and namespace in other branches
  1. 6 socialcalc.inc \socialcalc_import_date()
  2. 7.2 socialcalc.inc \socialcalc_import_date()
  3. 7 socialcalc.inc \socialcalc_import_date()

Convert a date from PHP to SocialCalc date/time value

Parameters

mixed $dateValue Unix timestamp or PHP DateTime object:

Return value

mixed SocialCalc date/time value or boolean False on failure

1 call to socialcalc_import_date()
theme_sheetnode_formatter_socialcalc_date in ./sheetnode.module

File

./socialcalc.inc, line 803
SocialCalc manipulation functions Translated from socialcalc-3.js and companion files

Code

function socialcalc_import_date($dateValue = 0) {
  $saveTimeZone = date_default_timezone_get();
  date_default_timezone_set('UTC');
  $retValue = False;
  if (is_object($dateValue) && $dateValue instanceof DateTime) {
    $retValue = socialcalc_import_date_explicit($dateValue
      ->format('Y'), $dateValue
      ->format('m'), $dateValue
      ->format('d'), $dateValue
      ->format('H'), $dateValue
      ->format('i'), $dateValue
      ->format('s'));
  }
  elseif (is_numeric($dateValue)) {
    $retValue = socialcalc_import_date_explicit(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue));
  }
  date_default_timezone_set($saveTimeZone);
  return $retValue;
}