Me and my Buddy YAWPS can help.

code to get time with time offset if needed.
my $date = get_date(0);
# -------------------------------------------------------------------- +- # Get the current date and time in epoch seconds. # -------------------------------------------------------------------- +- sub get_date { my $cfg{time_offset} = shift; return time + 3600 * $cfg{time_offset}; }


formats the date to many viewing styles
my $formated_date($date, 3);
# -------------------------------------------------------------------- +- # Format date output. # -------------------------------------------------------------------- +- sub format_date { my $date = shift || &get_date; my $type = shift || 1; # Get user profile. my $query = new CGI; my %user_data = authenticate(); # Get selected date format. my $sel_date_format = (exists $user_data{date_format}) ? $user_data{date_format} : $cfg{date_format}; $sel_date_format = ($type || $type ne '') ? $type : $cfg{date_ +format}; $date = ($date || $date ne '') ? $date : get_date() +; my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isds +t) = localtime($date + 3600 * $cfg{time_offset}); my ($formatted_date, $cmon, $cday, $syear); $year += 1900; $cmon = $mon + 1; $syear = sprintf("%02d", $year % 100); if ($hour < 10) { $hour = 0 . $hour; } if ($min < 10) { $min = 0 . $min; } if ($sec < 10) { $sec = 0 . $sec; } if ($cmon < 10) { $cmon = 0 . $cmon; } $cday = ($mday < 10) ? 0 . $mday : $mday; # Format: 01/15/00, 15:15:30 if (!$sel_date_format || $sel_date_format == 0) { $formatted_date = "$cmon/$cday/$syear, $hour:$min:$sec +"; } # Format: 15.01.00, 15:15:30 if ($sel_date_format == 1) { $formatted_date = "$cday.$cmon.$syear, $hour:$min:$sec +"; } # Format: 15.01.2000, 15:15:30 if ($sel_date_format == 2) { $formatted_date = "$cday.$cmon.$year, $hour:$min:$sec" +; } # Format: Jan 15th, 2000, 3:15pm if ($sel_date_format == 3) { my $ampm = 'am'; if ($hour > 11) { $ampm = 'pm'; } if ($hour > 12) { $hour = $hour - 12; } if ($hour == 0) { $hour = 12; } if ($mday > 10 && $mday < 20) { $cday = '<sup>th</sup> +'; } elsif ($mday % 10 == 1) { $cday = '<sup>st</sup>'; } elsif ($mday % 10 == 2) { $cday = '<sup>nd</sup>'; } elsif ($mday % 10 == 3) { $cday = '<sup>rd</sup>'; } else { $cday = '<sup>th</sup>'; } $formatted_date = "$months{$mon} $mday$cday, $year, $h +our:$min$ampm"; } # Format: 15. Jan 2000, 15:15 if ($sel_date_format == 4) { $formatted_date = "$wday. $months{$mon} $year, $hour:$ +min"; } # Format: 01/15/00, 3:15pm if ($sel_date_format == 5) { my $ampm = 'am'; if ($hour > 11) { $ampm = 'pm'; } if ($hour > 12) { $hour = $hour - 12; } if ($hour == 0) { $hour = 12; } $formatted_date = "$cmon/$cday/$syear, $hour:$min$ampm +"; } # Format: Sunday, 15 January, 2000 if ($sel_date_format == 6) { $formatted_date = "$week_days{$wday}, $mday $months{$m +on} $year"; } my $new_date22 = ''; my $new_mon = ''; # Format: year,month,day 20000 if ($sel_date_format == 7) { if($mday <= 9) { $new_date22 = "0$mday"; } else { $new_date22 += "$mday"; } if($mon <= 9) { $new_mon = "0$mon"; } else { $new_mon = "$mon" +; } #$cmon = $cmon - 1; $formatted_date = "$year$new_mon$new_date22"; } # Format: year,month,day 20000 if ($sel_date_format == 8) { #if(length($wday) < 2) { $wday = "0$wday"; } #$cmon = $cmon - 1; if($mon <= 9) { $new_mon = "0$mon"; } else { $new_mon += "$mon"; } $formatted_date = "$year$new_mon"; } # Format: 15/01/2000 - 03:15:30 (internal stats logfile format +). if ($sel_date_format == -1) { $formatted_date = "$cday/$cmon/$year - $hour:$min:$sec +"; } return $formatted_date; }


my $time_dif = calc_time_diff($in_date1, $in_date2, '');
This code will show the difference in hours or day
# -------------------------------------------------------------------- +- # Calculate difference between two dates. # -------------------------------------------------------------------- +- sub calc_time_diff { my ($in_date1, $in_date2, $type) = @_; my $result = $in_date1 - $in_date2; # Calculate difference in hours. if (!$type) { $result = int($result / 3600); } # Calculate difference in days. else { $result = int($result / (24 * 3600)); } return $result; }


Hope that helps! and you can Tank Yawps befor thanking me!

In reply to Re: ASCII chart that displays jobs that are running and jobs that are queued for a day by Anonymous Monk
in thread ASCII chart that displays jobs that are running and jobs that are queued for a day by wishartz

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.