how to change date format in php

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

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

3 thoughts on “how to change date format in php”

  1. Hi! Would you mind if I share your blog with my facebook group?
    There’s a lot of people that I think would really enjoy your content.
    Please let me know. Thanks

Leave a Reply to e hookah Cancel reply

Your email address will not be published.