Recently used Unix time to convert applications in MySQL and. Net. Keep this information in your blog.
How to get the present in different programming languages Unix time Stamp (Unix timestamp) ?
Java |
Time |
Javascript |
Math.Round (New Date (). GetTime ()/1000) GetTime () The unit of return value is 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 |
First import time and then Time.time () |
Ruby |
Get UNIX timestamp: Time.now or Time.new Show Unix timestamp: Time.now.to_i |
SQL Server |
SELECT DATEDIFF (S, ' 1970-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 in different programming languages Unix time Stamp (unixtimestamp) → 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 |
First my $time = Unix timestamp then my ($sec, $min, $hour, $day, $month, $year) = (localtime ($time)) [0,1,2,3,4,5,6] |
Php |
Date (' R ', Unix timestamp) |
PostgreSQL |
SELECT TIMESTAMP with Time ZONE ' epoch ' + Unix TIMESTAMP) * INTERVAL ' 1 second '; |
Python |
First import time and then Time.gmtime (Unix timestamp) |
Ruby |
time.at (Unix timestamp) |
SQL Server |
DATEADD (S, Unix timestamp, ' 1970-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 normal time in different programming languages → Unix time Stamp (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 |
First Use time::local then my $time = Timelocal ($sec, $min, $hour, $day, $month, $year); |
Php |
Mktime (hour, minute, second, month, Day, year) |
PostgreSQL |
SELECT Extract (Epoch from date ('yyyy-mm-dd HH:MM:SS')); |
Python |
First import time 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, ' 1970-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) |
Convert UNIX timestamps in different programming languages (Unix timestamp)