سؤال

Hi i'm using zendx form element date picker

$datadinascita = new ZendX_JQuery_Form_Element_DatePicker('datadinascita');
$datadinascita->setLabel('Data di nascita:')
    ->setJQueryParam('dateFormat', 'dd-mm-yy')
    ->setJQueryParam('changeYear', 'true')
    ->setJqueryParam('changeMonth', 'true')
    ->addValidator(new Zend_Validate_Date(array('format' => 'dd-mm-yyyy')))
    ->setRequired(true);

I would convert date dd-mm-yyyy to yyyy-mm-dd to insert in mysql. After that how i can re-convert the new date to original date for using that again?

هل كانت مفيدة؟

المحلول

Use the standard PHP date and strtotime functions:

<?php
$mysqlDate = date('Y-m-d', strtotime($datadinascitaDate);
$datadinascitaDate = date('d-m-y', strtotime($mysqlDate);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top