note 96801 added to function.mktime

From: Date: Tue, 16 Mar 2010 22:18:21 +0000
Subject: note 96801 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-167117@lists.php.net to get a copy of this message
Proper way to convert Excel dates into PHP-friendly timestamps using mktime(): // The date 6/30/2009 is stored as 39994 in Excel $days = 39994; // But you must subtract 1 to get the correct timestamp $ts = mktime(0,0,0,1,$days-1,1900); // So, this would then match Excel's representation: echo date("m/d/Y",$ts); Excel uses "number of days since Jan. 1, 1900" to store its dates. It also treats 1900 as a leap year when it wasn't, thus there is an extra day which must be accounted for in PHP (and the rest of the world). Subtracting 1 from Excel's number will fix this problem. Thanks to http://www.ozgrid.com/Excel/ExcelDateandTimes.htm for the details. ---- Server IP: 64.71.164.2 Probable Submitter: 137.48.131.9 ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- https://master.php.net/note/edit/96801 Del: integrated -- https://master.php.net/note/delete/96801/integrated Del: useless -- https://master.php.net/note/delete/96801/useless Del: bad code -- https://master.php.net/note/delete/96801/bad+code Del: spam -- https://master.php.net/note/delete/96801/spam Del: non-english -- https://master.php.net/note/delete/96801/non-english Del: in docs -- https://master.php.net/note/delete/96801/in+docs Del: other reasons-- https://master.php.net/note/delete/96801 Reject -- https://master.php.net/note/reject/96801 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167117) next »