On Monday 26 April 2004 06:07, Alok Bhatt wrote:
>
> Hi All,

Hello,

>  I am facing this strange problem related to dates.
> When I print the date using the system's date command,
> it prints correctly. But when I do the same using
> localtime, it shows the month as wrong (1 month
> previous.
>
> bash-2.03$ perl -e '@a=localtime; print "@a\n"'
> 18 4 8 26 3 104 1 116 0
>          ^^^
> bash-2.03$ perl -e '@a=localtime(time); print "@a\n"'
> 20 4 8 26 3 104 1 116 0
>          ^^^
> bash-2.03$ date
> Mon Apr 26 08:04:23 GMT 2004
> bash-2.03$
>
> It shows the month as March (3) instead of April. What
> could I be doing wrong?

localtime() and gmtime() return months in the range 0 to 11 so 3 is 
April.

perldoc -f localtime
perldoc -f gmtime


John
-- 
use Perl;
program
fulfillment


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to