함수 unixtime2datetime()

함수 unixtime2datetime(), unixtime to datetime
함수 timestamp2datetime(), timestamp to datetime
unix timestamp to datetime
ts2dt
ut2dt

1 Bash[ | ]

Bash
Copy
date +%Y-%m-%d\ %H:%M:%S -d @1406204196
# 2014-07-24 21:16:36
Bash
Copy
unixtime=1406204196
date +"%Y-%m-%d %H:%M:%S" --date @$unixtime
# 2014-07-24 21:16:36
Bash
Copy
unixtime=1406204196
datetime=`date +"%Y-%m-%d %H:%M:%S" --date @$unixtime`
echo $datetime
# 2014-07-24 21:16:36

2 C#[ | ]

C#
Copy
string dtStr = String.Format("{0:yyyy-MM-dd HH:mm:ss}", new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(1368597301));
// 2013-05-15 05:55:01
C#
Copy
public static String ts2dt(double ts)
{
  DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(ts).ToLocalTime();
  return String.Format("{0:yyyy-MM-dd HH:mm:ss}", dtDateTime);
}
...
Console.Write( ts2dt(1368597301) );
// 2013-05-15 14:55:01

3 Excel[ | ]

PHP
Copy
=1368597301/86400+25569
// 41409.24654 ← Format Cells: General
// 2013-05-15 05:55:01 ← Format Cells: (Custom) yyyy-mm-dd hh:mm:ss
PHP
Copy
=1368597301/60/60/24+DATE(1970,1,1)

4 JavaScript[ | ]

JavaScript
Copy
var unixtime = 1406204196;
var datetime = new Date(unixtime*1000).toISOString().substring(0,19).replace(/T/,' ');
JavaScript
Copy
var unixtime = 1406204196;
var d = new Date(unixtime *1000);
var datetime = d.getFullYear()+"-"+("0"+(d.getMonth()+1)).slice(-2)+"-"+("0"+d.getDate()).slice(-2)+" "
  +("0"+d.getHours()).slice(-2)+":"+("0"+d.getMinutes()).slice(-2)+":"+("0"+d.getSeconds()).slice(-2);

5 PHP[ | ]

PHP
Copy
echo date('Y-m-d H:i:s', 1368597301);
// 2013-05-15 14:55:01
PHP
Copy
$unixtime = 1406204196;
$datetime = date('Y-m-d H:i:s', $unixtime);
echo $datetime;
// 2014-07-24 21:16:36

6 Python[ | ]

Python
CPU
0.0s
MEM
8M
0.0s
Copy
import datetime
ut = 1406204196
dt = datetime.datetime.fromtimestamp( ut ).strftime('%Y-%m-%d %H:%M:%S')
print( dt ) # 2014-07-24 21:16:36
2014-07-24 12:16:36
Python
CPU
0.0s
MEM
8M
0.0s
Copy
import time
ut = 1406204196
dt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(ut) )
print( dt ) # 2014-07-24 21:16:36
2014-07-24 12:16:36

7 SQL[ | ]

7.1 MySQL[ | ]

MySQL
Copy
SELECT FROM_UNIXTIME( 1368597301 );
# 2013-05-15 14:55:01

8 같이 보기[ | ]