2016年3月20日日曜日

時間

言語
DateTime取得
TimeStamp取得
DateTime変換 => TimeStamp
TimeStamp => DateTime変換
Mysql
NOW()
UNIX_TIMESTAMP()
UNIX_TIMESTAMP()
FROM_UNIXTIME()
C++
time_t型, struct tm構造体, strftime(datetime, N, "%Y-%m-%d %H:%M:%S",tm )
time_t型, time(NULL)
time_t型,struct tm構造体,strptime(datetime, "%Y-%m-%d %H:%M:%S", &tm ), mktime(&tm)
time_t型,struct tm構造体, localtime(), strftime(datetime, N, "%Y-%m-%d %H:%M:%S",tm );
Java
new Date(), new SimpleDateFormat("yyyy'-'MM'-'dd' 'HH':'mm':'ss"), sdf.format()
new Date(), date.getTime()
new Date(), new SimpleDateFormat("yyyy'-'MM'-'dd' 'HH':'mm':'ss"),sdf.parse(),date.getTime()
new Date(), new SimpleDateFormat("yyyy'-'MM'-'dd' 'HH':'mm':'ss"), sdf.format()
JavaScript
new Date(), getFullYear()等のメソッド
parseInt( new Date() / 1000 )
Date.parse( datetime.replace( /-/g, '/') ) / 1000
new Date(timestamp*1000), getFullYear()等のメソッド
Perl
strftime( "%Y-%m-%d %H:%M:%S" , localtime())
time
Time::Local,DateTime::Format::Strptime,Time::Pieceモジュールを使う
strftime( "%Y-%m-%d %H:%M:%S" , localtime($utime))
PHP
date("Y-m-d H:i:s") / strftime("%Y-%m-%d %H:%M:%S")
time()
strtotime( $datetime )
date( "Y-m-d H:i:s", $utime ) / strftime("%Y-%m-%d %H:%M:%S", $utime )
Python
datetime.now().strftime( '%Y-%m-%d %H:%M:%S' )
int(time())
int( time.mktime( datetime.strptime( dtime, "%Y-%m-%d %H:%M:%S" ).timetuple() ) )
datetime.fromtimestamp( utime )
Ruby
Time.now.strftime "%Y-%m-%d %H:%M:%S"
Time.now.to_i
Time.parse(datetime).to_i
Time.at(utime).strftime "%Y-%m-%d %H:%M:%S"

0 件のコメント: