You are here

function socialcalc_export_datetime in Sheetnode 7.2

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

Convert a date from Excel to a PHP DateTime object.

Parameters

long $dateValueSocialCalc: date/time value SocialCalc date/time value

Return value

long PHP DateTime object

File

./socialcalc.inc, line 1100
SocialCalc manipulation functions.

Code

function socialcalc_export_datetime($dateValue = 0) {
  $dateTime = socialcalc_export_date($dateValue);
  $days = floor($dateTime / 86400);
  $time = round(($dateTime / 86400 - $days) * 86400);
  $hours = round($time / 3600);
  $minutes = round($time / 60) - $hours * 60;
  $seconds = round($time) - $hours * 3600 - $minutes * 60;
  $dateObj = date_create('1-Jan-1970+' . $days . ' days');
  $dateObj
    ->setTime($hours, $minutes, $seconds);
  return $dateObj;
}