My Opera is closing 1st of March

M.I.T = Multimedia IT dept.

Subscribe to RSS feed

time correction with perl & ntpdate

,

#!/usr/bin/perl

$timeserver="time.stdtime.gov.tw";

# get localtime via perl function
($sec,$min,$hour,$day,$mon,$year)=localtime(time);
$mon++;
if (length ($mon) == 1) {$mon = '0'.$mon;}
if (length ($day) == 1) {$day = '0'.$day;}
$year+=1900;

# get localtime via NTP
$time=`ntpdate -q $timeserver | sed '1d' | cut -d " " -f3` or die "Aborted";
($hour1,$min1,$sec1) = split(/:/,$time);
if (length ($hour1) == 1) {$hour1 = '0'.$hour1;}
if (length ($min1) == 1) {$min1 = '0'.$min1;}
if (length ($sec1) == 1) {$sec1 = '0'.$sec1;}

# time correction
$alltime="$mon$day$hour1$min1$year.$sec1";
print $alltime;
#system(date $alltime);
February 2014
M T W T F S S
January 2014March 2014
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28