I am trying to convert this time stamp into my time zone (EST), and display it like MM/DD/YY HH:MM PM.
I can't figure out what date function deals with the time zone.
Current time string (from XMLTV):
2006-02-10T23:00:00Z
[SOLVED] Date Function with time format 2006-02-10T23:00:00Z
Moderator: General Moderators
-
aischallenge
- Forum Newbie
- Posts: 3
- Joined: Fri Feb 10, 2006 9:15 am
This may help.
Code: Select all
//echo substr('abcdef', 1, 3); bcd
//0000-00-00 00:00:00
//year-mm-dd hh:mm:ss
$Year = substr($TimeStamp, 0, 4);
$Month = substr($TimeStamp, 5, 2);
$Day = substr($TimeStamp, 8, 2);
$Hour = substr($TimeStamp, 11, 2);
$Minutes = substr($TimeStamp, 14, 2);
$Seconds = substr($TimeStamp, 17, 2);Are you getting the timestamp from a database?
If so use date_format()
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
If so use date_format()
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
-
aischallenge
- Forum Newbie
- Posts: 3
- Joined: Fri Feb 10, 2006 9:15 am
I could pull the parts out as you describe, and then add / subtract the number of hours to get it into my time zone. However, I feel as though PHP should have a function that deals with this type of timestamp. Since XMLTV is providing it, I can't imagine that I would have to go through so much trouble.
http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
CONVERT_TZ(dt,from_tz,to_tz)
CONVERT_TZ() converts a datetime value dt from the time zone given by from_tz to the time zone given by to_tz and returns the resulting value. Time zones are specified as described in Section 5.11.8, “MySQL Server Time Zone Support”. This function returns NULL if the arguments are invalid.
If the value falls out of the supported range of the TIMESTAMP type when converted fom from_tz to UTC, no conversion occurs. The TIMESTAMP range is described in Section 11.1.2, “Overview of Date and Time Types”.
mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
-> '2004-01-01 13:00:00'
mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00');
-> '2004-01-01 22:00:00'
Note: To use named time zones such as 'MET' or 'Europe/Moscow', the time zone tables must be properly set up. See Section 5.11.8, “MySQL Server Time Zone Support”, for instructions.
-
aischallenge
- Forum Newbie
- Posts: 3
- Joined: Fri Feb 10, 2006 9:15 am