Sponsored Content
Top Forums Shell Programming and Scripting Time Zone - Day Light Savings Post 302133968 by photon on Monday 27th of August 2007 09:30:12 PM
Old 08-27-2007
DateTime module did the job very well.

Here is an example.

Code:
#! /usr/bin/perl
use Time::Local;

($s,$min,$h,$d,$m,$y,$dst) = (localtime)[0,1,2,3,4,5,8];
$m +=1;
$y += 1900;

########################################
use DateTime;

$dt = DateTime->new(
			year => $y,
			month => $m,
			day => $d,
			hour => $h,
			minute => $min,
			second => $s,
			nanosecond => 500000000,
			time_zone => 'America/New_York',
		);
$dt->set_time_zone('UTC');
print $dt->datetime; 
print $dt->time_zone_short_name;
print "\n";
$dt->set_time_zone('America/New_York');
print $dt->datetime;
print $dt->time_zone_short_name;
print "\n";
$dt->set_time_zone('America/Chicago');
print $dt->datetime;
print $dt->time_zone_short_name;
print "\n";

The output is:

Code:
2007-08-27T23:18:50UTC
2007-08-27T19:18:50EDT
2007-08-27T18:18:50CDT

 

9 More Discussions You Might Find Interesting

1. Solaris

Daylight Savings Time Fix

Hello, I've been looking at coming up with a time change on my Sun workstations since daylight savings time comes early this year. Someone at work told me that a sun patch is available if you have a maintenance contract. It was recommended to just set your systems to GMT time zone. How is this... (5 Replies)
Discussion started by: stocksj
5 Replies

2. Solaris

Daylight Savings Time Quirk

I am running a SUN E450 on solaris (5.7). I have applied the DST patch and the system time is correct. However when users login the get the time wrong (+4 hours) (I am in EDT Zone). Does anyone know where a system wide variable for this could be set. (Root user gets the right time) Frank (3 Replies)
Discussion started by: frankkahle
3 Replies

3. UNIX for Dummies Questions & Answers

Day light savings

Does anyone know how to reset a network printer to allow for the daylight savings?:) (0 Replies)
Discussion started by: Tweedy
0 Replies

4. AIX

Day Light Savings Time problem

Hi guys, OS: AIX 5.3.0.0 I'm from Portugal and I had problems about Day Light changing time, the hour's changes in first Sunday of November, but it's wrong because in Europe the day light need to change in last Sunday of October. My TZ is TZ=GMT0BST, that I think BST it's British Summer Time. I... (2 Replies)
Discussion started by: uadm26
2 Replies

5. AIX

Daylight savings time

Our aix unix box did not recognize daylight savings time since it was moved up. Could someone please give me the syntax to change the hour? I looked in man and couldn't find anything, or I missed it. I'm in 3rd grade so if you can, please provide specific instructions. Thanks! (2 Replies)
Discussion started by: vbagwell
2 Replies

6. AIX

Daylight savings time

Hello everyone The last sunday I have to check that my servers has change Daylight savings time but only two servers do it and all the rest doesnt. In smitty where I need to change, for my server take automatic the daylight savings time. Thanks for your tips The next its a message for... (0 Replies)
Discussion started by: lo-lp-kl
0 Replies

7. Shell Programming and Scripting

Date increment issue due to day light saving

The date increment worked fine until date reached 25/10, which is DLS change date. /bin/date --date="091025 1 day" +%y%m%d; the output is 091025 Is this a bug or something missing from the code ! (3 Replies)
Discussion started by: rajbravo
3 Replies

8. UNIX for Advanced & Expert Users

Auto resetting for Daylight Savings Time

We have an ancient Unix box from Siemens. Every year the system automatically changes the time for EST or DST. Unfortunately since the box is so old the dates that the times change are the old dates and not the current ones set during (I think) the Bush years. When I have to set the time back... (3 Replies)
Discussion started by: jbcamel
3 Replies

9. Solaris

showing 2 different time zones in global zone and nonglobal zone

can some one help me out as it is showing 2 different time zones in global zone and nonglobal zone .In global zone it is showing in GMT while in nonglobal zone i it showing as PDT. System in running with solaris 10 (3 Replies)
Discussion started by: ravijanjanam12
3 Replies
DateTime::Format::DateParse(3pm)			User Contributed Perl Documentation			  DateTime::Format::DateParse(3pm)

NAME
DateTime::Format::DateParse - Parses Date::Parse compatible formats SYNOPSIS
use DateTime::Format::DateParse; my $dt = DateTime::Format::DateParse->parse_datetime( $date ); my $dt = DateTime::Format::DateParse->parse_datetime( $date, $zone ); DESCRIPTION
This module is a compatibility wrapper around Date::Parse. USAGE
Import Parameters This module accepts no arguments to it's "import" method and exports no symbols. Methods Class Methods o parse_datetime($date [, $zone]) Accepts a Date::Parse compatible $date string and optionally a Time::Zone compatible $zone string. Returns a DateTime object. GOTCHAS
o If parse_datetime is called on a $date that doesn't know specify a timezone and $zone is not set, then the timezone of the returned DateTime object will be set to the "local" timezone. This is consistent with the behavior of Date::Parse. o If parse_datetime is called without a $zone but the $date string does specify a timezone/offset or if parse_datetime is called with a $zone that DateTime::TimeZone does not understand, the returned DateTime object will have it's timezone set to a fixed offset from UTC. This means that "DST" information is not available and date math will not reflect "DST" transitions. This may be resolved for true timezones by using the DateTime::TimeZone::Alias module to "alias" the Time::Zone timezone to an Olson DB name. This may be done automatically in a future release. CREDITS
Graham Barr (GBARR) <gbarr@pobox.com>, author of Date::Parse Everyone at the DateTime "Asylum". SUPPORT
Support for this module is provided via the <datetime@perl.org> email list. See <http://lists.perl.org/> for more details. AUTHOR
Joshua Hoblitt (JHOBLITT) <jhoblitt@cpan.org> COPYRIGHT
Copyright (c) 2005-6 Joshua Hoblitt. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the licenses can be found in the LICENSE file included with this module, or in perlartistic and perlgpl as supplied with Perl 5.8.1 and later. SEE ALSO
Date::Parse, Time::Zone, DateTime, DateTime::TimeZone, DateTime::TimeZone::Alias, <http://datetime.perl.org/> perl v5.10.1 2010-04-16 DateTime::Format::DateParse(3pm)
All times are GMT -4. The time now is 03:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy