The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what is wrong with the log function in c? return_user High Level Programming 2 05-02-2008 02:40 PM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 06:12 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 04:44 AM
Dynamic loader taking function from wrong lib rimon High Level Programming 1 01-29-2008 03:46 AM
Whats wrong with my function?? <newbie> riwa Shell Programming and Scripting 4 03-04-2006 01:14 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-04-2007
Registered User
 

Join Date: Apr 2007
Posts: 23
Stumble this Post!
Wrong date function

Hi,

I am getting some very strange output when using date function in PERL on Solaris.

Infact the month portion is wrong and it is 1 less then the current, means today it is responding as

month =3 , andthis should be 4 ------> April

Any help

my code is
Code:
($day, $month, $year) = (localtime)[3,4,5];

print $day;
print $month;
print $year;
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-04-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Code:
Infact the month portion is wrong and it is 1 less then the current, means today it is responding as 

month =3 , andthis should be 4 ------> April
Month starts from zero and this is not an error.
Reply With Quote
  #3 (permalink)  
Old 04-04-2007
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 767
Stumble this Post!
from the Perl manuals:
Quote:
$mday is the day of the month, and $mon is the month itself, in the range 0..11 with 0 indicating January and 11 indicating December.
Reply With Quote
  #4 (permalink)  
Old 04-04-2007
Registered User
 

Join Date: Apr 2007
Posts: 23
Stumble this Post!
THx for Help.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0