On Sat, 2010-07-17 at 19:47 +0800, Mohd Shakir bin Zakaria 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?
>
Of course it will, because you're only passing 0 values for the hours,
minutes and seconds. I'm not quite sure what the number 39604.62164
represents, or why it is coming up with a value like that when you're
passing the number in as the day argument to the date() call, but I
assume it allows for a fallover of the date value.
Look at the mktime() function on the man page and you'll see the correct
usage of it.
Thanks,
Ash
http://www.ashleysheridan.co.uk