date +%s
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
Literally speaking the epoch is Unix time 0 (midnight 1-1-1970), but 'epoch' is often used as a synonym for 'Unix time'.
Many Unix systems store epoch dates as a signed 32-bit integer, which might cause problems on January 19, 2038 (known as the Year 2038 problem or Y2038).
Perl | time |
PHP | time() |
Ruby | Time.now (or Time.new ). To display the epoch: Time.now.to_i |
Python | import time first, then time.time() |
Java | long epoch = System.currentTimeMillis()/1000; |
Microsoft .NET C# | epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; |
VBScript/ASP | DateDiff("s", "01/01/1970 00:00:00", Now()) |
Erlang | calendar:datetime_to_gregorian_seconds(calendar:now_to_universal_time( now()))-719528*24*3600. |
MySQL | SELECT unix_timestamp(now()) |
PostgreSQL | SELECT extract(epoch FROM now()); |
SQL Server | SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE()) |
JavaScript | Math.round(new Date().getTime()/1000.0) getTime() returns time in milliseconds. |
Unix/Linux | date +%s |
Other OS's | Command line: perl -e "print time" (If Perl is installed on your system) |
No comments:
Post a Comment