PHP工夫转换函数
正在PHP中工夫转换函数是“strtotime()”,该函数的作用是将任何英文文本的日期或工夫形容解析为Unix工夫戳,其语法为“strtotime(time,now)”,该函数胜利则前往工夫戳,不然前往FALSE。
简略例子
<?php echo strtotime("now"), "\n"; echo strtotime("10 September 2000"), "\n"; echo strtotime("+1 day"), "\n"; echo strtotime("+1 week"), "\n"; echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n"; echo strtotime("next Thursday"), "\n"; echo strtotime("last Monday"), "\n"; ?>
失败反省
<?php $str = 'Not Good'; // previous to PHP 5.1.0 you would compare with -1, instead of false if (($timestamp = strtotime($str)) === false) { echo "The string ($str) is bogus"; } else { echo "$str == " . date('l dS of F Y h:i:s A', $timestamp); } ?>
保举教程:《PHP教程》
以上就是PHP工夫转换函数若何应用?的具体内容,更多请存眷资源魔其它相干文章!
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!