This is a discussion on Re: [PHP] timestamp problem !! within the PHP General forums, part of the PHP Programming Forums category; On Wednesday 16 July 2003 02:00, Nabil wrote: > <?php > $timy = '20030714012548'; // time stamp from MySQL > ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Wednesday 16 July 2003 02:00, Nabil wrote:
> <?php > $timy = '20030714012548'; // time stamp from MySQL > echo strtotime = ($timy); > $date = ("Y-m-d" , $timy); > ?> > > and i have a wrong result.... how can i extract the YYYY-MM-DD from the > string $timy.... MySQL TIMESTAMP != UNIX TIMESTAMP Look up the date/time functions in MySQL. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Why do they put Braille dots on the keypad of the drive-up ATM? -- Why Why Why n29 */ |
|
|||
|
Nabil <nabil.attar@aws-syria.com> 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...functions.html http://www.mysql.com/doc/en/DATETIME.html > Nabil > Curt -- |
|
|||
|
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" <curt@zirzow.dyndns.org> ??????:20030714211135.GD45640@bagend.shire... > Nabil <nabil.attar@aws-syria.com> 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...functions.html > http://www.mysql.com/doc/en/DATETIME.html > > > > Nabil > > > > Curt > -- |
|
|||
|
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" <myhan@liumeiti.com> 写入消息新闻 :20030715004836.66543.qmail@pb1.pair.com... > 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" <curt@zirzow.dyndns.org> > ??????:20030714211135.GD45640@bagend.shire... > > Nabil <nabil.attar@aws-syria.com> 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...functions.html > > http://www.mysql.com/doc/en/DATETIME.html > > > > > > > Nabil > > > > > > > Curt > > -- > > |
|
|||
|
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... 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 ? Nabil "Jason Wong" <php-general@gremlins.biz> wrote in message news:200307150406.22944.php-general@gremlins.biz... > On Wednesday 16 July 2003 02:00, Nabil wrote: > > > <?php > > $timy = '20030714012548'; // time stamp from MySQL > > echo strtotime = ($timy); > > $date = ("Y-m-d" , $timy); > > ?> > > > > and i have a wrong result.... how can i extract the YYYY-MM-DD from the > > string $timy.... > > MySQL TIMESTAMP != UNIX TIMESTAMP > > Look up the date/time functions in MySQL. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.biz > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > ------------------------------------------ > Search the list archives before you post > http://marc.theaimsgroup.com/?l=php-general > ------------------------------------------ > /* > Why do they put Braille dots on the keypad of the drive-up ATM? > -- Why Why Why n29 > */ > |