python

import datetime
import time
a = '2020-04-08 15:28:59'
stamp = int(time.time())
print(datetime.datetime.fromtimestamp(stamp))
print(time.strftime("%Y-%m-%d %H:%M", time.localtime(stamp)))
print(time.mktime(time.strptime(a,'%Y-%m-%d %H:%M:%S')))

php

date_default_timezone_set('Asia/Shanghai');
$stringtime = date("Y-m-d H:i:s",time());
echo $stringtime."<br/>";
echo strtotime($stringtime)."<br/>";
echo date("Y/m/d G:i:s A",strtotime($stringtime));

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐