Convert UTC time to Date

Hi,
I need to convert a number representing time in UTC seconds to a date. Ex:
3BE0082C --> Oct 31 2001 15:31:08

I have tried the following perl command but it gives a different answer?
$ perl -e 'print scalar localtime(shift), "\n"' 3BE00B2C
Thu Jan 1 03:00:03 1970

Any ideas? Thanks. :slight_smile:

I think you're off by an hour... I get Wed Oct 31 14:31:08 2001

perl -e 'print scalar gmtime(hex shift), "\n"' 3BE00B2C

Very good, thanks for your help - I am confused as whay there is a difference. I am not working in US time zone but I think this shoud not mater - Is there any thing that my UNIX system has to specify to get the correct answer?

Have you tried my code? I get the same results on several systems. I cannot explain your result. :confused:

Yes I have tried your code.
I get the same result as yours.

However I was expecting to get OCT 31, 2001 15:31:08 - You see, this value appears in the documentation of a product we use and I have to make the code produce similar result.

I guess depending on the time zone I am in, UTC time may differ. May be because of day saving time or lack of it? Not sure?

But thanks much for your help.

Probably your documentation is in error. To duplicate the error:
perl -e 'print scalar gmtime((hex shift) + 3600), "\n"' 3BE00B2C

Cool!
Does UTC value have any thing to do with the specific zone or GMT time difference?

GMT is dead really. It was based the earth's rotation as measured by the Sun appearing overhead. UTC (universal time co-ordinated) is based on atomic time and is a sequence of accurately measured seconds, each having the same length. A bunch of radio telescopes watch the earth's rotation by looking at quasars, which are the most distant objects. When needed, a leap second is added to UTC to resync it to earth's rotation.

Thanks for your help.

Hi ,
I need to convert this time " 2009-04-06T18:21:36.539Z "

into this format " Mon 06 Apr 2009 23:51:36 +0530 "

Can anyone help me out or tell me the API's in C or Linux which can help to achieve it?

Regards,
Subodh

Hi ,
I need to convert this time " 2009-04-06T18:21:36.539Z "

into this format " Mon 06 Apr 2009 23:51:36 +0530 "

Can anyone help me out or tell me the API's in C or Linux which can help to achieve it?

Regards,
Subodh
Edit/Delete Message