function socialcalc_export_datetime in Sheetnode 6
Same name and namespace in other branches
- 5 socialcalc.inc \socialcalc_export_datetime()
- 7.2 socialcalc.inc \socialcalc_export_datetime()
- 7 socialcalc.inc \socialcalc_export_datetime()
Convert a date from Excel to a PHP DateTime object
Parameters
long $dateValue SocialCalc date/time value:
Return value
long PHP DateTime object
File
- ./
socialcalc.inc, line 832 - SocialCalc manipulation functions Translated from socialcalc-3.js and companion files
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;
}