d3bug3r
d3bug3r

Reputation: 2586

php date + time conversion

i would to know how can i parse date and time which we choose from date time picker into standard date('YmdHis') type of results?

$datetime = date('YmdHis);

enter image description here

eg date picker return result 11/13/2012 and time picker result is 2.30 AM, now i need to know how to joining them together and convert it to 20121113023000 format?

Upvotes: 0

Views: 388

Answers (3)

Akhilraj N S
Akhilraj N S

Reputation: 9457

echo date("YmdHis",strtotime('11/13/2012 2.30 AM'));

or

    $data = $_POST['date_picker']." ".$_POST['time_picker'];
    echo date("YmdHis",strtotime($data));

this will output that in required format

outputs

20121113023000

Upvotes: 1

Passerby
Passerby

Reputation: 10070

echo date("Y-m-d H:i:s",strtotime("11/13/2012 2.30 AM"));

outputs

2012-11-13 02:30:00

Upvotes: 1

Awais Qarni
Awais Qarni

Reputation: 18006

This should work

 $datatime = date('YmdHis',strtotime($_POST['datepickerfield']));

Upvotes: 1

Related Questions