|
|
This function convert a unix timestamp to string date like 1170882000 => YYYY-MM-DD HH:MM:SS
|
|
|
time2date
# *********************************************** # this function convert a unix timestamp to # string date like 1170882000 => YYYY-MM-DD HH:MM:SS function time2date () { local time=$1 local tzone=$2 [ -z "$tzone" ] && tzone=0 perl -e ' my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( '$time'+( '$tzone'*3600 ) ); $mon = $mon+1; $sec = sprintf( "%.2d", $sec ); $min = sprintf( "%.2d", $min ); $hour = sprintf( "%.2d", $hour ); $mon = sprintf( "%.2d", $mon ); $mday = sprintf( "%.2d", $mday ); $year = 1900+$year; print $year."-".$mon."-".$mday." ".$hour.":".$min.":".$sec; ' }
|
|
|
|