How to convert a date format to another format in PHP? - Programmers Heaven

Howdy, Stranger!

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

Categories

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

Damian99Damian99 USAPosts: 116Member

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

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

Tagged:

Comments

  • DavidMDavidM USAPosts: 342Member
    $originalDate = "2013-11-19";
    $convertedDate = date("d-m-Y", strtotime($originalDate));
    
  • dischobdischob BelgiumPosts: 2Member

    You can also use the PHP DateTime class:

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

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

  • AgriyaAgriya IndiaPosts: 2Member

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

Sign In or Register to comment.