Re: Convert excel time to date time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17 July 2010 12:47, Mohd Shakir bin Zakaria <mohdshakir@xxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux