Convert a date format in PHP

0 votes
I am trying to convert a date from yyyy-mm-dd to dd-mm-yyyy but however I don't know how the date function requires a timestamp, and I can't get a timestamp from this string.

How is this possible?
Feb 17 in Others by Rahul
• 8,980 points
57 views

1 answer to this question.

0 votes
Use strtotime() and date():
$originalDate = "2010-03-21"; $newDate = date("d-m-Y", strtotime($originalDate));

Note that this was a quick solution to the original question. For more extensive conversions, you should really be using the DateTime class to parse and format. 

answered Feb 17 by Aditya
• 7,280 points

Related Questions In Others

0 votes
0 answers

Date time convert in Replace activity in word document scope

we have input in excel  New date/Header 31/12/2020 31/12/2019 We  want ...READ MORE

Jun 22, 2020 in Others by Sapna
• 120 points

recategorized Jun 22, 2020 by Gitika 146 views
0 votes
1 answer

Change date format of cell in excel from dd.mm.yyyy to yyy/mm/dd ( excel version 2013 )

Hello :)   Excel’s Format Cells function can quickly ...READ MORE

answered Feb 9 in Others by gaurav
• 13,460 points
137 views
0 votes
0 answers

Convert Rows to Columns with values in Excel using custom format

1 I having a Excel sheet with 1 ...READ MORE

Feb 17 in Others by Edureka
• 13,640 points
28 views
0 votes
0 answers

How to convert a string to an integer in JavaScript?

How do I convert a string to ...READ MORE

May 2 in Others by Kichu
• 19,040 points
47 views
0 votes
1 answer

Format JavaScript date as yyyy-mm-dd

You could try using the following lines ...READ MORE

answered Feb 23 in Java-Script by Aditya
• 7,280 points
828 views
0 votes
0 answers

How do I use PHP to get the current year?

I want to put a copyright notice ...READ MORE

Jun 9 in PHP by Kichu
• 19,040 points
10 views
0 votes
0 answers

Format die(); Message in PHP

Is there a way to style the ...READ MORE

Jun 10 in PHP by narikkadan
• 10,840 points
10 views
0 votes
0 answers

Convert one date format into another in PHP

How can I convert one date format ...READ MORE

Jun 20 in PHP by Kithuzzz
• 320 points
4 views
0 votes
1 answer

How do I get the current date and time in PHP?

The time would go by your server ...READ MORE

answered Feb 16 in Others by Aditya
• 7,280 points
27 views
0 votes
1 answer

How to fix "Headers already sent" error in PHP

The functions that send and modify the ...READ MORE

answered Feb 17 in Others by Aditya
• 7,280 points
168 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP