使用日期和日期时间到时间
我一直在使用以下代码,没有任何问题,直到它最终登陆 Windows 服务器并决定产生错误:
$date = date('F d, Y', $data->e_date)
date($time_format, strtotime($date.' '.$data->e_time))
*(e_date 存储如下:“1293559200”,e_time 存储如下:“18: 00")*
错误如下:
date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in ...
据我了解,这是因为我在日期函数中使用 strtotime。所以我想知道解决或重写这个问题的优雅方法是什么?
我应该将整个 strtotime 输入到一个新变量中,即 $newdate ,然后以该形式返回日期,还是其他方式?
谢谢你!
I've been using the following bit of code without any issues till it finally landed on a windows server and decided to produce an error:
$date = date('F d, Y', $data->e_date)
date($time_format, strtotime($date.' '.$data->e_time))
*(e_date is stored like this: "1293559200", and e_time is stored like this: "18:00")*
The error is as such:
date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in ...
To my understanding this is because I am using strtotime within the date function. So what I'm wondering is what is an elegant method of solving or rewriting this?
Should I be feeding the entire strtotime in a new variable, i.e. $newdate and then back to date in that form, or otherwise?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用 UNIX TIMESTAMP,它将无法在 Windows 操作系统中正常工作。
尝试使用此函数进行转换。
将 20031230233029 转换为 30/12/2003 23:30:59
或这个,
或者您可以尝试使用另一个函数将 unix 时间戳转换为 mysql 时间戳
You are using UNIX TIMESTAMP it will not work properly in windows os systems.
Try to convert it using this function.
convert 20031230233029 to 30/12/2003 23:30:59
or this one
or you can try to convert the unix timestamp to mysql timestamp wth this another function