PHP Zend日期格式 [英] PHP Zend date format

查看:110
本文介绍了PHP Zend日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以下面的格式输入数据库的时间戳。

  yyyy-mm-dd hh:mm:ss 

如何获得上述格式?



当我使用

  $ date = new Zend_Date(); 

它返回月dd,yyyy hh:mm:ss PM p>

我还使用JavaScript日历插入选定的日期,并以 dd-mm-yyyy 格式返回



现在,我想将这两种格式转换成yyyy-mm-dd hh:mm:ss,可以插入到数据库中。 由于日期格式与数据库字段格式不匹配,日期未插入,仅填写* 00-00-00 00:00:00 *



感谢您的回答

解决方案

不知道这是否会帮助您,但尝试使用: / p>

  //显示日期和时间,
$ date-> get('YYYY-MM-dd HH :mm:ss');

//或仅显示日期
$ date-> get('YYYY-MM-dd')


I want to input a timestamp in below format to the database.

yyyy-mm-dd hh:mm:ss

How can I get in above format?

When I use

$date = new Zend_Date();

it returns month dd, yyyy hh:mm:ss PM

I also use a JavaScript calender to insert a selected date and it returns in dd-mm-yyyy format

Now, I want to convert these both format into yyyy-mm-dd hh:mm:ss so can be inserted in database. Because date format not matching the database field format the date is not inserted and only filled with *00-00-00 00:00:00*

Thanks for answer

解决方案

Not sure if this will help you, but try using:

 // to show both date and time,
 $date->get('YYYY-MM-dd HH:mm:ss');

 // or, to show date only
 $date->get('YYYY-MM-dd') 

这篇关于PHP Zend日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆