The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
time convert b_manu78 AIX 10 09-16-2008 01:47 PM
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 11:23 AM
Convert milliseconds to standard time chiru_h Shell Programming and Scripting 1 07-19-2007 01:45 PM
convert Julian date to calender date srikanthus2002 Shell Programming and Scripting 6 05-08-2007 06:27 AM
Date convert Help nzq71k UNIX for Dummies Questions & Answers 2 05-20-2003 04:25 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-18-2005
GNMIKE GNMIKE is offline
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.
  #2 (permalink)  
Old 10-18-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
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
  #3 (permalink)  
Old 10-19-2005
GNMIKE GNMIKE is offline
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?
  #4 (permalink)  
Old 10-19-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Have you tried my code? I get the same results on several systems. I cannot explain your result.
  #5 (permalink)  
Old 10-19-2005
GNMIKE GNMIKE is offline
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.
  #6 (permalink)  
Old 10-19-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Probably your documentation is in error. To duplicate the error:
perl -e 'print scalar gmtime((hex shift) + 3600), "\n"' 3BE00B2C
  #7 (permalink)  
Old 10-19-2005
GNMIKE GNMIKE is offline
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?
Sponsored Links
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0