dovs36921 2015-12-22 11:13
浏览 21

PHP / mysql:在php 5.3中获取正确的年份

My host updated from PHP 5.2 to PHP 5.3 and my date code no longer returns a year such as 2015 but instead a minus sign -1.

Wednesday November 30, 2015 

has become

Wednesday November 30, -1

This is evidently because the command date has changed. Despite trying out a lot of options, I can't get it to display properly

Here is my code that used to work and is now giving a -1 for the year.

function fulldatetime($datetime) {
$fullDate = strtotime($datetime);
$fullDate = date("l F jS, o, g:i A",$fullDate);
return $fullDate;
}

where $datetime is of the form: 2015-12-28 23:00:00

Can anyone explain to me the correct code to get the year to display right.

Thanks in advance for helping me to solve this vexing problem.

  • 写回答

2条回答 默认 最新

  • douyasihefu6214 2015-12-22 11:18
    关注

    use 'Y' instead of 'o' ? : date("l F jS, Y, g:i A",$fullDate);

    via http://php.net/manual/en/function.date.php

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题