how to change date format in php

We will show, how to change date format in php code. If you want to change the date format and save into mysql database. You can use our php code or script. You can use following php functions.

how to change date format in php

Let say you are getting date in yyyy-mm-dd format and you want to convert that into dd-mm-yyyy format and save into database. so you can use following function.

$timestamp = strtotime(your date variable);
$new_date = date('d-m-Y', $timestamp);

// or use can following code

$new_date = date('d-m-Y', strtotime(your date variable));

// or use can following code

strftime ($time, '%d %m %Y')
how to change date format in php

how to change date format in php

3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *