CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Another Date and time question

 



SirAnvil
Deleted

Jan 13, 2001, 12:02 PM

Post #1 of 3 (636 views)
Another Date and time question Can't Post

check this out. I've got a code as listed in the frequently asked questions

@date_time = localtime;
$date = "@date_time";
($sec, $min, $hours, $mday, $month, $year, $wday, $yday, $isdst) = split(/\s/, $date);
$year += 1900;

Then i have a code that takes this buggar and does the following

print "$year-$month-$mday\n";

and this is what I get this$
./time
2001-0-12

and when I use this print statement
print "$year$month$yday\n";

2001012

The month is showing up as zero when it's supposed to be 01 or just 1. Ughn. I know the clock is set right on the server cause when I execut this
$date

i get this
Sat Jan 13 15:03:53 EST 2001

Any idea's?

PS(it's in year-month-day format because I'm working with MySQL)

SirAnvil
www.christiangamers.org


Jasmine
Administrator / Moderator

Jan 13, 2001, 2:01 PM

Post #2 of 3 (632 views)
Re: Another Date and time question [In reply to] Can't Post

FAQ Correction:


Code
($sec, $min, $hours, $mday, $month, $year, $wday, $yday, $isdst) = localtime();   
# or localtime(time) -- time is the default value
$year += 1900; # add 1900 to year because $year is the current year minus 1900
$month++; # increment because month index starts at 0



SirAnvil
Deleted

Jan 13, 2001, 6:48 PM

Post #3 of 3 (628 views)
Re: Another Date and time question [In reply to] Can't Post

Worked like a charm. Thanx. Now if I can get this other issued delt with. :)

SirAnvil
www.christiangamers.org

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives