How can I obtain the current UNIX timestamp (UNIX timestamp) in different programming languages )? |
Java |
Time |
Javascript |
Math. Round (new date (). gettime ()/1000) gettime () returns a value in milliseconds. |
Microsoft. NET/C # |
Epoch = (datetime. Now. touniversaltime (). ticks-621355968000000000)/10000000 |
MySQL |
Select unix_timestamp (now ()) |
Perl |
Time |
PHP |
Time () |
PostgreSQL |
Select extract (epoch from now ()) |
Python |
Import time first and then time. Time () |
Ruby |
Obtain UNIX timestamp: time. Now or time. New Display UNIX timestamp: time. Now. to_ I |
SQL Server |
Select datediff (S, '2017-01-01 00:00:00 ', getutcdate ()) |
Unix/Linux |
Date + % s |
VBScript/asp |
Datediff ("S", "01/01/1970 00:00:00", now ()) |
Other operating systems (If Perl is installed in the System) |
Command Line status: Perl-e "Print time" |
|
How to Implement UNIX timestamps in different programming languages (UNIX Timestamp) → Normal time? |
Java |
String date = new java. Text. simpledateformat ("DD/MM/YYYY hh: mm: SS"). Format (New java. util. Date (UNIX Timestamp* 1000 )) |
Javascript |
First var unixtimestamp = new date (UNIX Timestamp* 1000) Then commontime = unixtimestamp. tolocalestring () |
Linux |
Date-d @UNIX Timestamp |
MySQL |
From_unixtime (UNIX Timestamp) |
Perl |
My $ time =UNIX TimestampThen my ($ sec, $ min, $ hour, $ day, $ month, $ year) = (localtime ($ time) [, 6] |
PHP |
Date ('R ',UNIX Timestamp) |
PostgreSQL |
Select timestamp with Time Zone 'epoch' +UNIX Timestamp) * Interval '1 second '; |
Python |
Import time first and then time. gmtime (UNIX Timestamp) |
Ruby |
Time. (UNIX Timestamp) |
SQL Server |
Dateadd (S,UNIX Timestamp, '2017-01-01 00:00:00 ') |
VBScript/asp |
Dateadd ("S ",UNIX Timestamp, "01/01/1970 00:00:00 ") |
Other operating systems (If Perl is installed in the System) |
Command Line status: Perl-e "Print scalar (localtime (UNIX Timestamp))" |
|
How to implement common time → UNIX timestamp in different programming languages (UNIX Timestamp)? |
Java |
Long epoch = new java. Text. simpledateformat ("Dd/mm/yyyy hh: mm: SS"). Parse (" 01/01/1970 01:00:00 "); |
Javascript |
VaR commontime = new date (date. UTC (Year,Month-1,Day,Hour,Minute,Second)) |
MySQL |
Select unix_timestamp (Time) Time Format: YYYY-MM-DD hh: mm: SS or yymmdd or yyyymmdd |
Perl |
Use Time: local first and then my $ time = timelocal ($ sec, $ min, $ hour, $ day, $ month, $ year ); |
PHP |
Mktime (Hour,Minute,Second,Day,Month,Year) |
PostgreSQL |
Select extract (epoch from date ('YYYY-MM-DD hh: mm: Ss.')); |
Python |
Import time first and then int (time. mktime (time. strptime ('YYYY-MM-DD hh: mm: Ss.',' % Y-% m-% d % H: % m: % s '))) |
Ruby |
Time. Local (Year,Month,Day,Hour,Minute,Second) |
SQL Server |
Select datediff (S, '2017-01-01 00:00:00 ',Time) |
Unix/Linux |
Date + % s-d "Jan 1, 1970 00:00:01" |
VBScript/asp |
Datediff ("S", "01/01/1970 00:00:00 ",Time) |
|