Oracle下时间转换在几种语言中的实现

时间:2021-09-18 05:02:53

cshellperlphp下的日期时间转换:秒数与人类可读日期scalarlocaltime与secondssince`00:00:001970-01-01UTC'

scalarlocaltime26-bytestring与secondssince`00:00:001970-01-01UTC'

(1970年1月1日凌晨零点以来的秒数)

thenumberofsecondsthathavepassedsincetheEpoch:00:00:00January1,1970,CoordinatedUniversalTime(UTC).

c:

《AdvancedProgrammingintheUNIXEnvironment:SecondEdition》

简称《APUE》Seciont6.10Figure6.8.Relationshipofthevarioustimefunctions说的清楚

#include

time_ttime(time_t*calptr);

structtm*localtime(consttime_t*calptr);

structtm*gmtime(consttime_t*calptr);

time_tmktime(structtm*tmptr);

char*asctime(conststructtm*tmptr);

char*ctime(consttime_t*calptr);

size_tstrftime(char*restrictbuf,size_tmaxsize,

constchar*restrictformat,

conststructtm*restricttmptr);

shell:

%date+%s

1128621784

%date-d"1970-01-01UTC1128621784seconds"

FriOct702:03:04CST2005

date-d"1970-01-01UTC1128621784seconds"+"%Y-%m-%d%H:%M:%S"

2005-10-0702:03:04

perl:

%perl-e'printscalarlocaltime1128621784'

FriOct702:03:042005

php:

date('Y-m-dH:i:s',time());