当前时间: | 1734903407 | 2024-12-23 05:36:47 【】 | |
时区设置: | |||
时间日期: | |||
时间戳: |
java
time
JavaScript
Math.round(new Date().getTime()/1000)
getTime()返回数值的单位是毫秒
Microsoft .NET / C#
epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000
MySQL
SELECT unix_timestamp(now())
php
time();
strtotime('now');
Perl
time
PostgreSQL
SELECT extract(epoch FROM now())
Python
import time
time.time()
Ruby
获取Unix时间戳:Time.now 或 Time.new
显示Unix时间戳:Time.now.to_i
SQL Server
SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE())
Linux Shell
date +%s
java
String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date(Unix timestamp * 1000))
JavaScript
var unixTimestamp = new Date(Unix timestamp * 1000)
commonTime = unixTimestamp.toLocaleString()
Microsoft .NET / C#
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime); return dtStart.Add(toNow);
MySQL
from_unixtime(Unix timestamp)
php
date('Y-m-d H:i:s', Unix timestamp)
Perl
my $time = Unix timestamp
my ($sec, $min, $hour, $day, $month, $year) = (localtime($time))[0,1,2,3,4,5,6]
PostgreSQL
SELECT TIMESTAMP WITH TIME ZONE 'epoch' + Unix timestamp) * INTERVAL '1 second';
Python
import time
time.gmtime(Unix timestamp)
Ruby
Time.at(Unix timestamp)
SQL Server
DATEADD(s, Unix timestamp, '1970-01-01 00:00:00')
Linux Shell
date -d @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))
Microsoft .NET / C#
DateTime DateStart= new DateTime(1970,1,1,8,0,0);
return Convert.ToInt32((DateTime.Now - DateStart).TotalSeconds);
MySQL
SELECT unix_timestamp(time)
时间格式: YYYY-MM-DD HH:MM:SS 或 YYMMDD 或 YYYYMMDD
php
mktime(hour, minute, second, month, day, year)
Perl
use Time::Local
my $time = timelocal($sec, $min, $hour, $day, $month, $year);
PostgreSQL
SELECT extract(epoch FROM now())
Python
import time
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)
Linux Shell
date +%s -d"Jan 1, 1970 00:00:01"