Sponsored Content
Top Forums Shell Programming and Scripting Convert UTC time into current UNIX sever time zone Post 302879311 by blackrageous on Wednesday 11th of December 2013 06:56:28 PM
Old 12-11-2013
This does seem to be a bit vague. Here is a useful tip and in this case I am using the korn shell. The idea here is to temporarily define the TZ environment variable; that is....
Code:
TZ=CDT date

would define the TZ var for the execution of the date command...regardless of what the default TZ setting is.

By example...
Code:
[josephgr@oc0887178221 ~]$ date; TZ=UTC date
Wed Dec 11 17:57:03 CST 2013
Wed Dec 11 23:57:03 UTC 2013

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Unix Time to Standard Time

I have a list of interfaces and time the interface was last active. I can't figure out how to convert the time in the second column, Fa1/14 0 Se0/0/0 0 Fa1/11 0 Fa1/9 0 Fa1/0 0 Se0/0/1 1240401408 Gi1/0 0 Fa0/0 1240401408 Fa1/3 0 Fa1/8 0 Fa1/15 0 Fa1/13 0 Fa1/10 0 Fa1/1 0 Fa1/12... (7 Replies)
Discussion started by: mrlayance
7 Replies

2. Shell Programming and Scripting

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. :) (10 Replies)
Discussion started by: GNMIKE
10 Replies

3. AIX

Convert UTC time to local time ?

Hello, Using AIX6.1 box. I have UTC time value and need to convert it to local time value - I mean time zone and DST should be taken into consideration. I hope it could be done using shell environment - I don't want to write a program. thanks Vilius ---------- Post updated at 02:30 PM... (2 Replies)
Discussion started by: vilius
2 Replies

4. Shell Programming and Scripting

Find and Convert UTC Time to PST Time

Hello All - I have a script that grabs data from the net and outputs the following data 46029 46.144 -124.510 2010 07 26 22 50 320 4.0 6.0 2.2 9 6.8 311 1012.1 -0.9 13.3 13.5 13.3 - - 46041 47.353 -124.731 2010 07 26 22 50 250 2.0 3.0 1.6 8 6.4 - 1011.6 - ... (0 Replies)
Discussion started by: drexnefex
0 Replies

5. AIX

Convert time (YYYYMMDD HHMMSS) to UTC

Okay, so let's say we have a string like: 20110105_193345 This represents: January 5th, 2011 = 20110105 24-hour style time 19:33:45 = 193345 Okay, so we have our time. It's January 5th, 2011 at 19:33:45. I want to convert this time from Eastern Time Zone (which it currently is in)... (1 Reply)
Discussion started by: syndex
1 Replies

6. UNIX for Dummies Questions & Answers

UTC time and Local time

Hi, A few days ago I changed my CentOS box's timezone to -07:00. Now the date commands output look like this (run almost simultaneously, less than 1 second delay).. # date Mon Sep 5 20:23:40 PDT 2011 # date -u Tue Sep 6 03:24:05 UTC 2011 The hours difference seems correct, but why is... (2 Replies)
Discussion started by: forte712
2 Replies

7. Solaris

modifying date and time and time zone on solaris 5.10 with (redundant server) veritas

I have a cluster of two Solaris server (veritas cluster). one working and the other is standby I am going to change the date on them , and am looking for a secure solution as it is giving an important service. my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies

8. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies

9. AIX

Change Time Zone to UTC without DST

Hello AIX friends, We have timezone settings on our AIX 6.1 boxes set to Europe/London. How can I change it to UTC timezone with Daylight saving disabled. After running "smit chtz_user" I don't see UTC option in the listing. Please advise. TIA (3 Replies)
Discussion started by: prvnrk
3 Replies

10. UNIX for Dummies Questions & Answers

How to change the time zone in UNIX??

hi, my system date and time zone is PDT. whenever i append date time stamp to a file it appends the system date thats PDT date time zone. i want to append GMT time zone. is there a mechanism or option which can append the date time stamp according to GMT. (4 Replies)
Discussion started by: Little
4 Replies
Jifty::DateTime(3pm)					User Contributed Perl Documentation				      Jifty::DateTime(3pm)

NAME
Jifty::DateTime - a DateTime subclass that knows about Jifty users SYNOPSIS
use Jifty::DateTime; # Get the current date and time my $dt = Jifty::DateTime->now; # Print out the pretty date (i.e., today, tomorrow, yesterday, or 2007-09-11) Jifty->web->out( $dt->friendly_date ); # Better date parsing my $dt_from_human = Jifty::DateTime->new_from_string("next Saturday"); DESCRIPTION
Jifty natively stores timestamps in the database in GMT. Dates are stored without timezone. This class loads and parses dates and sets them into the proper timezone. To use this DateTime class to it's fullest ability, you'll need to add a "time_zone" method to your application's user object class. This is the class returned by "user_object" in Jifty::CurrentUser. It must return a value valid for using as an argument to DateTime's "set_time_zone()" method. new ARGS See "new" in DateTime. If we get what appears to be a date, then we keep this in the floating datetime. Otherwise, set this object's timezone to the current user's time zone, if the current user's user object has a method called "time_zone". now ARGS See "now" in DateTime. If a time_zone argument is passed in, then this wrapper is effectively a no-op. OTHERWISE this will always set this object's timezone to the current user's timezone. Without this, DateTime's "now" will set the timezone to UTC always (by passing "time_zone => 'UTC'" to "Jifty::DateTime::new". We want Jifty::DateTime to always reflect the current user's timezone (unless otherwise requested, of course). from_epoch ARGS See "from_epoch" in DateTime and "now" in Jifty::DateTime. This handles the common mistake of "from_epoch($epoch)" as well. current_user [CURRENTUSER] When setting the current user, update the timezone appropriately. If an "undef" current user is passed, this method will find the correct current user and set the time zone. current_user_has_timezone Return timezone if the current user has one. This is determined by checking to see if the current user has a user object. If it has a user object, then it checks to see if that user object has a "time_zone" method and uses that to determine the value. set_current_user_timezone [DEFAULT_TZ] set_current_user_time_zone [DEFAULT_TZ] Set this Jifty::DateTime's timezone to the current user's timezone. If that's not available, then use the passed in DEFAULT_TZ (or GMT if not passed in). Returns the Jifty::DateTime object itself. If your subclass changes this method, please override "set_current_user_timezone" not "set_current_user_time_zone", since the latter is merely an alias for the former. new_from_string STRING[, ARGS] Take some user defined string like "tomorrow" and turn it into a "Jifty::Datetime" object. If a "time_zone" argument is passed in, that is used for the input time zone. If the string appears to be a _date_, the output time zone will be floating. Otherwise, the output time zone will be the current user's time zone. As of this writing, this uses Date::Manip along with some internal hacks to alter the way Date::Manip normally interprets week day names. This may change in the future. friendly_date Returns the date given by this "Jifty::DateTime" object. It will display "today" for today, "tomorrow" for tomorrow, or "yesterday" for yesterday. Any other date will be displayed in "ymd" format. We currently shift by "24 hours" to detect yesterday and tomorrow, rather than "1 day" because of daylight saving issues. "1 day" can result in invalid local time errors. is_date Returns whether or not this "Jifty::DateTime" object represents a date (without a specific time). Dates in Jifty are in the floating time zone and are set to midnight. get_tz_offset Returns the offset for a time zone. If there is no current user, or the current user's time zone is unset, then UTC will be used. The optional datetime argument lets you calculate an offset for some time other than "right now". jifty_serialize_format This returns a DateTime (or string) consistent with Jifty's date format. WHY
? There are other ways to do some of these things and some of the decisions here may seem arbitrary, particularly if you read the code. They are. These things are valuable to applications built by Best Practical Solutions, so it's here. If you disagree with the policy or need to do it differently, then you probably need to implement something yourself using a DateTime::Format::* class or your own code. Parts may be cleaned up and the API cleared up a bit more in the future. SEE ALSO
DateTime, DateTime::TimeZone, Jifty::CurrentUser LICENSE
Jifty is Copyright 2005-2010 Best Practical Solutions, LLC. Jifty is distributed under the same terms as Perl itself. perl v5.14.2 2011-01-24 Jifty::DateTime(3pm)
All times are GMT -4. The time now is 10:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy