PHP date 格式化一个本地时间/日期 date (PHP 4, PHP 5) date — 格式化一个本地时间/日期 说明 string date ( string $format [, int $timestamp ] ) 返回将整数 timestamp 按照给定的格式字串而产生的字符串.如果没有给出时间戳则使用本地当前时间.换句话说,timestamp 是可选的,默认值为 time(). Tip 自 PHP 5.1.1 起有几个有用的常量可用作标准的日期/时间格式来指定 format
1.获取时间并且格式化输出 new Date().toLocaleString('cn',{hour12:false}) //2018/12/6 17:57:15 new Date().toLocaleDateString('cn',{hour12:false}) //2018/12/6 new Date().toLocaleTimeString('cn',{hour12:false}) //17:54:01 2.补充分别获取日期和时间 myDate.getYear(); // 获取当前年份(2
获取当前时间 func Now func Now() Time 1 Now returns the current local time. func (Time) UTC func (t Time) UTC() Time 1 UTC returns t with the location set to UTC. func (Time) Unix func (t Time) Unix() int64 1 Unix returns t as a Unix time, the number of se