$date2and you have a handy countdown to any time you want!
#!/usr/bin/perl ###Load Modules use warnings; use strict; use Date::Manip; use Time::HiRes; use CGI; my $cgi = new CGI; ###Set $err so you can specify a mode for &DateCalc my $err; ###Set Dates to Calculate for, then Find Difference my $curtime = getime(); my $date1 = &ParseDate($curtime); my $date2 = &ParseDate("03:14:06 Jan 19 2038"); my $delta = &DateCalc($date1,$date2,\$err,1); ###Populate Data hash my %data; @data{qw/years months weeks days hours minutes seconds/} = $delta =~ / +(\d+)/g; ###Begin HTML Output, yes this is bad, but it's quick-n-dirty :) print $cgi->header(); print<<END; <html> <head> <title>Countdown to the Death of 32bit time_t</title> </head> <body> <h3> Countdown to the Death of 32bit time_t (Tue Jan 19 3:14:06 203 +8 GMT) </h3> <hr> <p> $data{years} Year(s) </p> <p> $data{months} Months(s) </p> <p> $data{weeks} Weeks(s) </p> <p> $data{days} Day(s) </p> <p> $data{hours} Hour(s) </p> <p> $data{minutes} Minutes(s) </p> <p> $data{seconds} Second(s) </p> <hr> <p> END my $now = &getime(); print<<END; It is curently $now </p> </bodY> </html> END ###Get current time (GMT) sub getime() { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime( +); ###Correct for 'zero math' $year += 1900; $mon += 1; my $time = "$hour:$min:$sec $mon\/$mday\/$year"; return $time; }
Yes I know it's not the best script around, or best written, but I like it
Edit: Changed
sub getime() { to sub getime { and fixed the month 'count-from-zero' bug.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Death of time_t Timer
by Nkuvu (Priest) on Jun 18, 2003 at 21:34 UTC | |
by OverlordQ (Hermit) on Jun 18, 2003 at 22:34 UTC | |
by Nkuvu (Priest) on Jun 18, 2003 at 22:46 UTC |