The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
time convert b_manu78 AIX 10 3 Weeks Ago 10:47 AM
Processing a log file based on date/time input and the date/time on the log file primp Shell Programming and Scripting 4 03-16-2008 07:23 AM
Convert milliseconds to standard time chiru_h Shell Programming and Scripting 1 07-19-2007 10:45 AM
convert Julian date to calender date srikanthus2002 Shell Programming and Scripting 6 05-08-2007 03:27 AM
Date convert Help nzq71k UNIX for Dummies Questions & Answers 2 05-20-2003 01:25 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-18-2005
Registered User
 

Join Date: Jul 2005
Posts: 45
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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-18-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,453
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
Reply With Quote
  #3 (permalink)  
Old 10-18-2005
Registered User
 

Join Date: Jul 2005
Posts: 45
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?
Reply With Quote
  #4 (permalink)  
Old 10-18-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,453
Have you tried my code? I get the same results on several systems. I cannot explain your result.
Reply With Quote
  #5 (permalink)  
Old 10-18-2005
Registered User
 

Join Date: Jul 2005
Posts: 45
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.
Reply With Quote
  #6 (permalink)  
Old 10-18-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,453
Probably your documentation is in error. To duplicate the error:
perl -e 'print scalar gmtime((hex shift) + 3600), "\n"' 3BE00B2C
Reply With Quote
  #7 (permalink)  
Old 10-19-2005
Registered User
 

Join Date: Jul 2005
Posts: 45
Cool!
Does UTC value have any thing to do with the specific zone or GMT time difference?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0