phpzend-frameworkdatezend-dateformatdatetime

PHP Zend date format


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


Solution

  • 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')