1. 时间戳- ---> 普通时间(Sql Servere)

Declare @time bigint
set @time=1631081001 --2021-09-08 14:03:21
SELECT DATEADD(second,@time,'1970-01-01 08:00:00')

result: 2021-09-08 14:03:21

 

2. 普通时间 ------>时间戳

Declare @datetime datetime
set @datetime= '2021-09-08 14:03:21'
SELECT DATEDIFF(second, '1970-01-01 08:00:00', @datetime)

 

result: 1631081001