LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 11-24-2010, 11:19 AM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Rep: Reputation: 30
need to covert date/time value in a report to various timezones


(SLES 10, report generated by extract function & reparsed using bash script)

I have a report in which I have to take the date/time value and change those values to time adjusted to the timezones appropriate to each device (found in last field).

example:

2010-11-05 23:22:48.000000, 0, 0316, 36, 392, 0.00, 0, 0, 0.00, 0.00, 0, 0, UT01

where field 1 is in MST and I want it printed in CST value (which would be "2010-11-06 03:22:48.000000" if I can ever figure this out...).

Is there a built in bash or GNU awk function to take field $1 and convert it to a different timezone value such as CST, EST and PST? I appreciate your input. Thanks in advance.
 
Old 11-24-2010, 11:30 AM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Check out the man page for the "date" command.

Regards,

Fordeck
 
Old 11-24-2010, 11:30 AM   #3
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Original Poster
Rep: Reputation: 30
Mmmkay, answered my own question. The date function works:

tempdate=`awk {print $1} myreport`
date -d "%tempdate 1 hour ago" +Y-%m-%d\ %H:%m:%S

to set PST dates,

and
date -d "%tempdate 1 hour" +Y-%m-%d\ %H:%m:%S
date -d "%tempdate 2 hours" +Y-%m-%d\ %H:%m:%S

to set CST and EST dates.

I'll likely set up a "for in do done" statement and embed a "case in $timezone" statement beneath that to adjust everything that needs it and avoid adjusting anything that doesn't.

 
Old 11-24-2010, 11:45 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
To get time relative to a Time Zone you could 'env TZ=$TZ /bin/date' where TZ is one of PST, CST, etc, you get the point.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DST Time Change for positive timezones not working ravindra1103 Linux - General 2 01-12-2010 11:54 PM
sarg - generating report via date - date mandrakeBren Linux - Newbie 0 10-29-2009 07:31 AM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
Bug report: wrong date/time format in last visited wipe LQ Suggestions & Feedback 0 07-29-2004 06:21 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 03:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration