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....
would define the TZ var for the execution of the date command...regardless of what the default TZ setting is.
By example...
This isn't a ksh feature, it is standard behavior required for any shell conforming to the POSIX standards or the Single UNIX Specifications. But, the format shown above is not correct. A valid setting for TZ will include at least the zone's name and offset from UTC. The normal setting for Texas in the United States would be TZ=CST6CDT (not TZ=CDT) and TZ=UTC happens to work because the offset from UTC to UTC is 0, but the output from the commands:
will be identical except for the difference in the time zone name. Compare the results above with:
where you'll see a 6 hour difference in time (this time of year) as well as a difference in the time zone name. The output from the above three commands should be something like:
Last edited by Don Cragun; 12-11-2013 at 08:20 PM..
Reason: Fix typo.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
jifty::datetime
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)