Re: [PHP] timestamp problem !!

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 > ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-14-2003
Jason Wong
 
Posts: n/a
Default Re: [PHP] timestamp problem !!

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
*/

Reply With Quote
  #2 (permalink)  
Old 07-14-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] timestamp problem !!

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
--
Reply With Quote
  #3 (permalink)  
Old 07-15-2003
Myhan
 
Posts: n/a
Default Re: [PHP] timestamp problem !!

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
> --



Reply With Quote
  #4 (permalink)  
Old 07-15-2003
Myhan
 
Posts: n/a
Default Re: [PHP] timestamp problem !!

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
> > --

>
>



Reply With Quote
  #5 (permalink)  
Old 07-15-2003
Nabil
 
Posts: n/a
Default Re: [PHP] timestamp problem !!

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
> */
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0