Yes I really know this isn't much of a CUFP, since it's been done many times before, but just change
$date2
and 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.


In reply to Death of time_t Timer by OverlordQ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.