function socialcalc_export_date in Sheetnode 7.2
Same name and namespace in other branches
- 5 socialcalc.inc \socialcalc_export_date()
- 6 socialcalc.inc \socialcalc_export_date()
- 7 socialcalc.inc \socialcalc_export_date()
Convert a date from SocialCalc to a Unix timestamp.
Parameters
long $dateValueSocialCalc: date/time value SocialCalc date/time value
Return value
long Unix timestamp
1 call to socialcalc_export_date()
- socialcalc_export_datetime in ./
socialcalc.inc - Convert a date from Excel to a PHP DateTime object.
File
- ./
socialcalc.inc, line 1066 - SocialCalc manipulation functions.
Code
function socialcalc_export_date($dateValue = 0) {
$myBaseDate = 25569;
// Adjust for the spurious 29-Feb-1900 (Day 60).
if ($dateValue < 60) {
--$myBaseDate;
}
// Perform conversion.
if ($dateValue >= 1) {
$utcDays = $dateValue - $myBaseDate;
$returnValue = round($utcDays * 24 * 60 * 60);
if ($returnValue <= PHP_INT_MAX && $returnValue >= -PHP_INT_MAX) {
$returnValue = (int) $returnValue;
}
}
else {
$hours = round($dateValue * 24);
$mins = round($dateValue * 24 * 60) - round($hours * 60);
$secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
$returnValue = (int) gmmktime($hours, $mins, $secs);
}
return $returnValue;
}