Top
>
CGI(perl)
> localtime
localtime
#!/usr/bin/perl
( $sec , $min , $hour , $mday , $mon , $year , $wday , $yday , $isdst ) = localtime;
$mon += 1;
$year += 1900;
$yobi = ('日','月','火','水','木','金','土')[$wday];
print "Content-type:text/html\n\n";
printf( "sec = $sec" );
print "<br>";
printf( "min = $min" );
print "<br>";
printf( "hour = $hour" );
print "<br>";
printf( "mday = $mday" );
print "<br>";
printf( "mon = $mon" );
print "<br>";
printf( "year = $year" );
print "<br>";
printf( "$yobi" );
print "<br>";
printf( "yday = $yday" );
print "<br>";
printf( "isdst = $isdst" );
print "<br>";
printf( "$year/$mon/$mday ($yobi) $hour:$min:$sec " );
●出力結果
sec = 15
min = 38
hour = 10
mday = 25
mon = 8
year = 2016
木
yday = 237
isdst = 0
2016/8/25 (木) 10:42:56
時間の取得。
年には1900を、月には1を足すと現在の値になります。
曜日も取得できます。