Re: Convert excel time to date time

From: Date: Mon, 19 Jul 2010 11:33:43 +0000
Subject: Re: Convert excel time to date time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-306994@lists.php.net to get a copy of this message
On 17 July 2010 12:47, Mohd Shakir bin Zakaria <mohdshakir@gmail.com> wrote: > Hi, > > I've been trying to convert this excel date to the date time format, > but only managed to get it up to the seconds; > > The following code; > > ######### > $data=39604.62164; > date("Y-m-d",mktime(0,0,0,1,$data-1,1900)); > ######### > > will give this output > 2008-06-05 > > changing it to > > ######## > date("H-i-s",mktime(0,0,0,1,$data-1,1900)); > ######## > > will only give > 00-00-00 > > The output I'm looking for is like this one; > 2008-06-05 14:55:09 > > Any idea? <?php function xls2tstamp($date) { return ((($date > 25568) ? $date : 25569) * 86400) - ((70 * 365 + 19) * 86400); } echo date('r', xls2tstamp(39604.62164)); ?> outputs ... Thu, 05 Jun 2008 15:55:09 +0100

« previous php.general (#306994) next »