JS Gets the Unix timestamp (Unix timestamp) __js

Source: Internet
Author: User
Tags posix postgresql

JS gets the Unix time stamp

The Unix timestamp (Unix timestamp), or Unix time (Unix times), POSIX time (POSIX times), is a time representation, defined as the total number of seconds from GMT January 01, 1970 00:00 00 seconds to the present. Unix timestamps are used not only in UNIX systems, Unix-like systems, but also in many other operating systems.

A considerable portion of the operating system currently uses 32-bit binary digits to represent time. Unix timestamps of this type of system can be used up to GMT January 19, 2038 03:14 07 seconds (binary: 01111111 11111111 11111111 11111111). A second later, the binary number becomes 10000000 00000000 00000000 00000000, and an overflow error occurs, causing the system to misinterpret the time as December 13, 1901 20:45 52 seconds. This is likely to cause a software failure, or even a system paralysis. Systems that use 64-bit binary digits to represent time (up to GMT 292,277,026,596, December 04 15:30 08 seconds) are less likely to experience such overflow problems. how to get the current UNIX timestamp (Unix timestamp) in different programming languages.

Java Time
Javascript Math.Round (New Date (). GetTime ()/1000)
GetTime () returns the unit of the number 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 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 UNIX timestamp (Unix timestamp) → Normal time in different programming languages.
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 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 Import time First 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.