You are here: Re: Converting dates « PHP Language « IT news, forums, messages
Re: Converting dates

Posted by Simon Williams on 11/21/47 11:30

Thanks mate that is awesome!

The format is a TdateTime from delphi. I parsing some XML so i dont have
control over the format.

With the code I found it doesnt work with:

$secs = intval( 60 * 60 * 24 * doubleval( '0.'.intval($dt[1]) ) );

but I chnaged it to:

$secs = intval( 60 * 60 * 24 * doubleval( '0.'.$dt[1] ) );

and it work great thanks very much for your help

-simon

On Fri, 28 Oct 2005 02:36:06 +0800, Hilarion <hilarion@SPAM.op.SMIECI.pl>
wrote:

>
> <?php
> $dt = '38644.8661226852';
> $dt = explode( '.', $dt );
>
> // We get the date portion (as UNIX timestamp, which is "native"
> // PHP format).
> $tm = mktime( 0, 0, 0, 1, (1 + intval( $dt[0] ) - 25569), 1970 );
> $tm = date( 'Y-m-d', $tm );
> echo 'Date: ' . $tm . "\n";
>
> // We'll need it later split to year, month and day parts.
> $tm = explode( '-', $tm );
>
> // We get the time portion recalculated to seconds of the day.
> $secs = intval( 60 * 60 * 24 * doubleval( '0.'.intval($dt[1]) ) );
> echo 'Secs: ' . $secs . "\n";
>
> // We join all this to get date with time and get it as timestamp
> $tm = mktime( 0, 0, $secs, intval( $tm[1] ), intval( $tm[2] ),
> intval( $tm[0] ) );
> echo 'Time: ' . date( 'Y-m-d H:i:s', $tm ) . "\n";
> ?>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация