如何从mysql datetime列返回转换后的时间格式?
16lz
2021-01-22
I'm trying to convert datetimte to something shorter, but i get some error as below.
我试着将datetimte转换为更短的,但是我得到了如下的错误。
Warning:
date_format()
expects parameter 1 to be DateTime, string given in ...警告:date_format()期望参数1为DateTime,字符串在…
CODE
代码
$datetime = '2012-03-24 17:45:12';
$time = date_format($datetime, 'g:i A');
echo $time;
What i'm i doing wring? Thanks.
我在做什么?谢谢。
3 个解决方案
#1
2
Try this with DateTime
试试这个,DateTime
$date = new DateTime("2012-03-24 17:45:12");
echo $date->format("g:i A");
更多相关文章
- 如何在mysql数据库中找到类似的二进制字符串?
- MySQL数据库导入或者同步大量数据时数据丢失解决方案
- 关于mysql 和Oracle的一大堆麻烦问题的解决方案
- 关于mysql无法添加中文数据的问题以及解决方案
- SQL从结果数据库中选择subCode及其得分,并将其输出为一个字符串
- [JavaScript] 将字符串数组转化为整型数组
- JavaScript 字符串函数 之查找字符方法(一)
- 范围变量值的变化没有反映在我的字符串中
- Javascript字符串替换为动态创建的模式。