- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: Perl Script /Time function giving different re...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-02-2007 09:50 AM
тАО07-02-2007 09:50 AM
Here is a simple perl script that displays the current system time:
==============================================
($seconds, $minutes, $hour, $dayofmonth, $month, $year, $dayofweek, $dayofyear, $dst) = localtime(time);
print $seconds, " Second\n";
print $minutes, " Minute\n";
print $hour, " Hour\n";
print $dayofmonth, " Day of Month\n";
print $month, " Month\n";
print $year, " Year\n";
print $dayofweek, " Day of week\n";
print $dayofyear, " Day of year\n";
print $dst, " DST\n";
==============================================
When executed on a Windows server, it gives the correct "hour" value, but, when executed on another windows server (which is in the same timezone and physical location as the first server), it gives an "hour" value that is ahead by 5 hours.
Windows Admins are sure that the OS setup (as far as time/timezone/etc) is correct. Why would I be seeing this difference? Would this be something Windows related or the Perl related?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-02-2007 10:02 AM
тАО07-02-2007 10:02 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-02-2007 10:10 AM
тАО07-02-2007 10:10 AM
Re: Perl Script /Time function giving different results
This is certainly related to your OS configuration and is NOT a Perl "problem".
Perl uses the standard libc library routines which in turn are sensitive to the environment's timezone.
You might examine what each server shows for:
# perl -le 'print join " =L:G= ", scalar localtime, scalar gmtime'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2007 05:19 AM
тАО07-03-2007 05:19 AM
Re: Perl Script /Time function giving different results
With localtime(), I get the following output on the problem windows server:
27 Second
6 Minute
18 Hour
3 Day of Month
6 Month
107 Year
2 Day of week
183 Day of year
1 DST
With gmtime(), I get the following output on the problem windows server:
59 Second
6 Minute
17 Hour
3 Day of Month
6 Month
107 Year
2 Day of week
183 Day of year
0 DST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2007 05:20 AM
тАО07-03-2007 05:20 AM
Re: Perl Script /Time function giving different results
When executing the command you suggested, I get the following error:
F:\usr\OV\conf\OpC>c:\perl\bin\perl -le 'print join " =L:G= ", scalar localtime,
scalar gmtime'
Can't find string terminator "'" anywhere before EOF at -e line 1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2007 05:28 AM
тАО07-03-2007 05:28 AM
Re: Perl Script /Time function giving different results
If you posted your reply within 13 minutes of your run, the gmtime is fine but your timezone for local time is for Europe, 1 hour ahead of GMT. Or 5 hours ahead of EDT.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2007 05:37 AM
тАО07-03-2007 05:37 AM
Re: Perl Script /Time function giving different results
Here is the gmtime (using the gmtime() function) on the good server:
46 Second
36 Minute
17 Hour
3 Day of Month
6 Month
107 Year
2 Day of week
183 Day of year
0 DST
Here is the gmtime (using the gmtime() function) on the bad server:
42 Second
37 Minute
17 Hour
3 Day of Month
6 Month
107 Year
2 Day of week
183 Day of year
0 DST
Both have been posted here within seconds of running the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2007 05:56 AM
тАО07-03-2007 05:56 AM
Re: Perl Script /Time function giving different results
Your GMT time on both is fine. If this was a UNIX system, it would mean your timezone setting was bad on the one. Since this is Windows, you should have started your thread there.