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
41 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 140 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 Edureka
• 8,820 points
64 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
• 9,700 points
21 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
• 17,220 points
32 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
143 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
513 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
9,026 views
0 votes
4 answers

How can we compare dates in java?

public static String daysBetween(String day1, String day2) ...READ MORE

answered Sep 5, 2018 in Java by Sushmita
• 6,900 points
338 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
17 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
51 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