Wrong date function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wrong date function
# 1  
Old 04-04-2007
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;

# 2  
Old 04-04-2007
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.
# 3  
Old 04-04-2007
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.
# 4  
Old 04-04-2007
THx for Help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wrong test interpretation for simple function.

Hello everyone, I have written simple script below to check if ip is added to interface #!/usr/local/bin/bash IFCONFIG="/sbin/ifconfig" SERVICE="/usr/sbin/service" IP="79.137.X.X" GREP=$(${IFCONFIG} | grep ${IP}) ip_quantity_check () { echo ${GREP} | wc -l } if ];... (2 Replies)
Discussion started by: bryn1u
2 Replies

2. Shell Programming and Scripting

Python - Function print vs return - whats wrong

All, I have a basic buzz program written in python with return function. If i change return with print,it works fine but i want to know whats wrong with return statement.Can anyone help me whats wrong with this #!/usr/bin/python def div4and6(s,e): for i in range(s,e+1): if... (5 Replies)
Discussion started by: oky
5 Replies

3. Shell Programming and Scripting

Date as suffix in rsync... what am I doing wrong?

#!/bin/bash currentdatee=$(date +%D-%R) rsync -autb --backup-dir="/home/kyle/USBSYNC/OLDFILES/CRUZEREDGE1/" --suffix="$currentdatee" /mnt/backup/* /home/kyle/USBSYNC/CRUZEREDGE1/ The rsync line simply doesn't work when I try this. It'll work if I make the suffix something static. I feel... (1 Reply)
Discussion started by: corrado33
1 Replies

4. Solaris

v240 -- wrong date

after shutting down the server and the ILOM/ALOM, its date seems to go back to 1977..rather than current date.. problem with battery on ILOM/ALOM ??:( (1 Reply)
Discussion started by: ppchu99
1 Replies

5. Shell Programming and Scripting

Whats wrong in the Function ?

Need your assistance, to find the bug in the function. Function usage erroring out even after passing parameters. usage() { if || ; then echo "************************************************************" echo " CHECK USAGE FOR CORRECT PARAMETERS ... (26 Replies)
Discussion started by: raghunsi
26 Replies

6. Shell Programming and Scripting

Function returns wrong values - solved

Hi I have a small function which returns a wrong value. The function tries to make a connection to oracle database and tries to get the open_mode of the database in the variable status. However when a database is down the value of the status column is set to READWRITE i am not sure why. I... (0 Replies)
Discussion started by: xiamin
0 Replies

7. Shell Programming and Scripting

Date function

I read man page for etc/shadow field.. on the 8th field, i assume that's the field to change account expire date. my question is: What value does the 8th field keep? i assume it's 13514 instead of "Date" value such as 11/10/08. on the man page, it said: " expire value = 13514 = jan 1,... (11 Replies)
Discussion started by: c00kie88
11 Replies

8. Programming

what is wrong with the log function in c?

Hi I looked up the reference but couldn't figure out whats wrong with my log funtions in ANSI C, need this log functions for a memory compiler, please help!! #include <stdio.h> #include <math.h> int main(void) { double d ; double logB(double x, double base); printf(" ... (2 Replies)
Discussion started by: return_user
2 Replies

9. Programming

Dynamic loader taking function from wrong lib

Hi, I have two dynamically loaded libraries (shared objects), both of which include functions of the same name - foo. When I call 'foo' from libA, it takes it from libB, although it is implemented in libA as well. Since we need the function to be called from libA, we tried linking it with the... (1 Reply)
Discussion started by: rimon
1 Replies

10. Shell Programming and Scripting

Whats wrong with my function?? <newbie>

First of all im using Bash, on a Debian-based machine. I tried to write a function that if the ls program found listed more than 25 lines I would automaticly use "ls | less". Its on another computer but if I recall it looked something like this... Note: some code may look strange because im on... (4 Replies)
Discussion started by: riwa
4 Replies
Login or Register to Ask a Question