How to convert a date format to another format in PHP?

How can I convert a date format in PHP to another format.

Ex. yyyy-mm-dd => dd-mm-yyyy


  • $originalDate = "2013-11-19";
    $convertedDate = date("d-m-Y", strtotime($originalDate));
  • dischobdischob Belgium

    You can also use the PHP DateTime class:

    1. $originalDate = new DateTime("2013-11-19");

    2. $originalDate->format("d-m-Y");

  • Check out the discussion to know more simplest & efficient ways.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!