note 74369 modified in function.strtotime by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 04:07:31 +0000 |
| Subject: | note 74369 modified in function.strtotime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142110@lists.php.net to get a copy of this message | ||
This function inputs a date sting and outputs an integer that is the internal representation of days
that spreadsheets use. Post this value into a cell, then format that cell as a Date.
<?php
function conv_to_xls_date($Date) {
// Returns the Excel/Calc internal date integer from either an ISO date YYYY-MM-DD or MM/DD/YYYY
formats.
return (int) (25569 + (strtotime("$Date 12:00:00") / 86400));
}
?>
example:
<?php
$Date = "04-07-2007";
$Days = conv_to_xls_date($Date);
?>
$Days will contain 39179
--was--
This function inputs a date sting and outputs an integer that is the internal representation of days
that spreadsheets use. Post this value into a cell, then format that cell as a Date.
function conv_to_xls_date($Date) {
// Returns the Excel/Calc internal date integer from either an ISO date YYYY-MM-DD or MM/DD/YYYY
formats.
return (int) (25569 + (strtotime("$Date 12:00:00") / 86400));
}
example:
$Date = "04-07-2007";
$Days = conv_to_xls_date($Date);
$Days will contain 39179
http://php.net/manual/en/function.strtotime.php