3.141.27.244 |    

Navigation

Google Advertisement

This function convert a unix timestamp to string date like 1170882000 => YYYY-MM-DD HH:MM:SS

time2date
  1. # ***********************************************
  2. # this function convert a unix timestamp to
  3. # string date like 1170882000 => YYYY-MM-DD HH:MM:SS
  4.  
  5. function time2date () {
  6.  
  7. local time=$1
  8. local tzone=$2
  9. [ -z "$tzone" ] && tzone=0
  10.  
  11. perl -e '
  12. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( '$time'+( '$tzone'*3600 ) );
  13. $mon  = $mon+1;
  14. $sec  = sprintf( "%.2d", $sec  );
  15. $min  = sprintf( "%.2d", $min  );
  16. $hour = sprintf( "%.2d", $hour );
  17. $mon  = sprintf( "%.2d", $mon  );
  18. $mday = sprintf( "%.2d", $mday );
  19. $year = 1900+$year;
  20. print $year."-".$mon."-".$mday." ".$hour.":".$min.":".$sec;
  21. '
  22.  
  23. }
Parsed in 0.002 seconds at 386.57 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 5 users online.

Tags Cloud

Latest snippets
str2seconds
(Bash::Function)
is_integer
(Bash::Function)
file_rotate
(Bash::Function)
confirm
(Bash::Function)
is_workingtime
(Bash::Function)
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)