05-10-2013
Thank you both.
That seems to be the problem - mystery solved - and both were correct !
Under OLSON format the TZ depends on the data in /usr/share/lib/zoneinfo and under POSIX format we specify the DST details directly and so it does not depend on anything else.
Using zdump -vc to dump the zoneinfo database shows that there are gaps in the data stored w.r.t. DST for different years.
Specifically in the cases where the above code does not work the data for 1970 is missing.
We have another AIX machine where Europe/London was available but details for 1970 is missing and so the code gives the wrong output:
zdump -vc 1970 Europe/London
<snip>
Europe/London Sun Oct 29 02:00:00 1967 UTC = Sun Oct 29 02:00:00 1967 GMT isdst=0
Europe/London Sun Feb 18 01:59:59 1968 UTC = Sun Feb 18 01:59:59 1968 GMT isdst=0
Europe/London Sun Feb 18 02:00:00 1968 UTC = Sun Feb 18 03:00:00 1968 BST isdst=1
Europe/London Sat Oct 26 22:59:59 1968 UTC = Sat Oct 26 23:59:59 1968 BST isdst=1
Europe/London Sat Oct 26 23:00:00 1968 UTC = Sun Oct 27 00:00:00 1968 BST isdst=0
Europe/London Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 03:14:07 2038 GMT isdst=0
Europe/London Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 03:14:07 2038 GMT isdst=0
<snip>
And where the data is available (and correct), the code gives the right output.
So the moral of the story is :
1) Using Posix format is reliable and to be preferred
2) If using Olson format check the zoneinfo database using zdump and if the data for the year is there and correct all is well. Otherwise first ensure that the zoneinfo database is corrected.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
ok here is a perl date question not asked befor.
i know i am feeling small for not knowing. BUT!!!!
$ENV{TZ}="US/Central";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();
how can i do the addition to year so i can get the current year w/o going $ntime=$year+1900;... (3 Replies)
Discussion started by: Optimus_P
3 Replies
2. UNIX for Advanced & Expert Users
hi,
how to convert the localtime to unixtime?
i have date from the date command in unix
i want to convert it into unixtime
thnx (2 Replies)
Discussion started by: AshishK
2 Replies
3. Solaris
I have this command in my script and it's working fine with AIX:
ls init?*.ora 2>/dev/null | egrep -i -e ""
the same command is failing in Solaris 10.
does anyone have better idea how to make it work for both ?
Thanks (1 Reply)
Discussion started by: talashil
1 Replies
4. Shell Programming and Scripting
Strange behaviour of the strftime() function from gawk (3.1.5):
$ awk 'BEGIN{print strftime("%T", 3600)}'
> 02:00:00
$ awk 'BEGIN{print strftime("%T", 0)}'
> 01:00:00
Obviously something with DST but I can not figure out why? To me 3600 epoch seconds remains 01:00, DST or not.
From... (2 Replies)
Discussion started by: ripat
2 Replies
5. Shell Programming and Scripting
Hello All,
I am facing a warning "Argument "" isn't numeric in localtime at"
what i m using is below
my $timestamp = Timestamp(time);
go_log("###############$timestamp###############");
can some one please suggest the way to avoid this message :confused: (6 Replies)
Discussion started by: NIMISH AGARWAL
6 Replies
6. Shell Programming and Scripting
Hi Experts,
I know how to handle normal date changes in perl. Most of my requirement are full filled with following:
$date1 = strftime "%Y%m%d",localtime;
$date2 = strftime "%Y%m%d",localtime(time -24 * 60 * 60);
$date3 = strftime "%Y%m%d",localtime(time +24 * 60 * 60);
$date4 = strftime... (4 Replies)
Discussion started by: mtomar
4 Replies
7. Programming
HI,
i wish to convert a millsec value to a readable string format.
the one option is to use strftime.
However this is a bit costly (1-5 micros).
is there a a faster way to do so with just string manipulation
(Note i have the date object which has the time details but wish o avoid strftime) (2 Replies)
Discussion started by: wojtyla
2 Replies
8. Shell Programming and Scripting
Hi,
I'm new to perl scripting and am trying it out.
I have a file written in the following format:
myfile-MMDDYY where MM is the number of the Month; DD the Day and YY the last two of the year... (Apologies for dumbing this down; I'm trying to be clear).
There is a new file put onto my... (2 Replies)
Discussion started by: Astrocloud
2 Replies
9. Shell Programming and Scripting
Hi all,
a=$1 ##
b=`echo "86400 * $a"|bc`
`perl -e 'use POSIX qw(strftime);$now_string = strftime "%d/%m/%Y", localtime(time-$b); print $now_string,"\n";' > date_file`
but im always getting current date; can any one suggest me any the improvement
the above works fine if i use some thing... (2 Replies)
Discussion started by: zozoo
2 Replies
10. Shell Programming and Scripting
cat file
41285.000034722223 41285.000567129631
41285.000069444446 41285.001122685186
41285.000092592592 41285.001620370371
41285.000138888892 41285.00340277778
41285.000185185185 41285.000405092593
41285.000196759262 41285.000856481478
41285.000208333331 41285.000717592593... (5 Replies)
Discussion started by: phpshell
5 Replies
LEARN ABOUT PHP
datetime.gettimezone
DATETIME.GETTIMEZONE(3) 1 DATETIME.GETTIMEZONE(3)
DateTime::getTimezone - Return time zone relative to given DateTime
Object oriented style
SYNOPSIS
public DateTimeZone DateTime::getTimezone (void )
DESCRIPTION
DateTimeZone DateTimeImmutable::getTimezone (void ) DateTimeZone DateTimeInterface::getTimezone (void )
Procedural style
DateTimeZone date_timezone_get (DateTimeInterface $object)
Return time zone relative to given DateTime.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3)
RETURN VALUES
Returns a DateTimeZone object on success or FALSE on failure.
EXAMPLES
Example #1
DateTime.getTimezone(3) example
Object oriented style
<?php
$date = new DateTime(null, new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName();
?>
Procedural style
<?php
$date = date_create(null, timezone_open('Europe/London'));
$tz = date_timezone_get($date);
echo timezone_name_get($tz);
?>
The above examples will output:
Europe/London
SEE ALSO
DateTime.setTimezone(3).
PHP Documentation Group DATETIME.GETTIMEZONE(3)