timegm()

G

Gauri

This is the time I have in GMT
time: 6/26/2007 12:00:26 AM

I want to convert it to epoch format in CST timezone:
Using the timegm() function, this is the answer I get:
GMT_epochtime: 1182859226

Is CST_epochtime same as GMT_epochtime for any given time?

Also when I try to convert the above epoch time back to readable time,
using function gmtime()
($r_sec,
$r_min,
$r_hour,
$r_day,
$r_month,
$r_year,
$r_weekday,
$r_yearday,
$r_isdst) = gmtime($GMT_epochtime);

I get $r_hour = 12.

I'm expecting 00 since the time given above is 12 AM.

Where am I going wrong? else how do I know if $r_hour =12 is AM or PM?

-Gauri
 
G

Gunnar Hjalmarsson

Gauri said:
This is the time I have in GMT
time: 6/26/2007 12:00:26 AM

I want to convert it to epoch format in CST timezone:
Using the timegm() function, this is the answer I get:
GMT_epochtime: 1182859226

Then you don't pass the correct values to timegm().

C:\home>type test.pl
use Time::Local;
print timegm( 26, 0, 0, 26, 6-1, 2007 ), "\n";

C:\home>test.pl
1182816026

C:\home>
Is CST_epochtime same as GMT_epochtime for any given time?

Yes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top