The quick and easy to convert a mysql timestamp is to use the
UNIX_TIMESTAMP(field_name) function in mysql when you query the data.  It
converts a 14-digit mysql timestamp to a standard unix timestamp.
"Myhan" <[EMAIL PROTECTED]> 写入消息新闻
:[EMAIL PROTECTED]
> mysql's timstamp in this case is in the format:
> YYYYMMDDHHMMSS
> and it's default value is current time.
>
> | TIMESTAMP(14) | YYYYMMDDHHMMSS |
> | TIMESTAMP(12) | YYMMDDHHMMSS   |
> | TIMESTAMP(10) | YYMMDDHHMM     |
> | TIMESTAMP(8)  | YYYYMMDD       |
> | TIMESTAMP(6)  | YYMMDD         |
> | TIMESTAMP(4)  | YYMM           |
> | TIMESTAMP(2)  | YY             |
>
> After having some trouble checking deltas between DB-Timestamps and my
> server time, I use this to convert something like a MySQL-Timestamp(14) to
> the UNIX format:
>
> $Timestamp="20030423145607";
> $UnixTimestamp = strtotime (substr_replace (substr (substr
> ($Timestamp,0,2).chunk_split (substr ($Timestamp,2,6),2,"-").chunk_split
> (substr ($Timestamp,8),2,":"),0,19)," ",10,1));
>
> "Curt Zirzow" <[EMAIL PROTECTED]>
> ??????:[EMAIL PROTECTED]
> > Nabil <[EMAIL PROTECTED]> wrote:
> > > thanks Jason, you've been  always helping me ...
> > >
> > > Please i still have some fog regading this.. can u expaling me more
> about
> > > the timestamp and unix timestamp...
> >
> > mysql's timstamp in this case is in the format:
> >    YYYYMMDDHHMMSS
> >
> > Unix timstamp number of seconds since 1970-01-01
> >
> > > and regaring me issue i have a string with '20030714012548'  what ever
i
> got
> > > it from (because i m getting this from MSSQL some time and then read
it
> from
> > > MySQL, and i need to desplay it in as 2003-07-14 only ..
> > >
> > > What' shall i do ?
> >
> > Read:
> > http://www.mysql.com/doc/en/Date_and_time_functions.html
> > http://www.mysql.com/doc/en/DATETIME.html
> >
> >
> > > Nabil
> > >
> >
> > Curt
> > --
>
>



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

Reply via email to