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, 2022 in Others by Rahul
• 9,680 points
3,850 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, 2022 by Aditya
• 7,680 points

Related Questions In Others

0 votes
1 answer

Convert column in excel date format (DDDDD.tttt) to datetime using pandas

Given # s = df['date'] s 0 ...READ MORE

answered Oct 2, 2022 in Others by narikkadan
• 63,600 points
3,516 views
0 votes
1 answer

Convert Excel's "41014" date to actual date in PHP or JavaScript

PHPExcel Date handling code: public static function ExcelToPHP($dateValue ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,600 points
4,404 views
0 votes
1 answer

Convert text date/time to a real date time in excel

For a date conversion: =DATEVALUE(TEXT(A1,"MM/DD/YYYY")) For a time conversion: =TIMEVALUE(TEXT(A1,"HH:MM:SS")) For ...READ MORE

answered Dec 19, 2022 in Others by narikkadan
• 63,600 points
562 views
0 votes
1 answer

Add a correct format date in Excel file with Python openpyxl

Use just datetime.fromisoformat(row['Date']) but I didn't have ...READ MORE

answered Feb 9, 2023 in Others by narikkadan
• 63,600 points
2,615 views
0 votes
1 answer

Format JavaScript date as yyyy-mm-dd

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

answered Feb 23, 2022 in Java-Script by Aditya
• 7,680 points
4,679 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, 2022 in PHP by Kichu
• 19,040 points
623 views
0 votes
0 answers

Format die(); Message in PHP

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

Jun 10, 2022 in PHP by narikkadan
• 63,600 points
420 views
0 votes
0 answers

Convert one date format into another in PHP

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

Jun 20, 2022 in PHP by Kithuzzz
• 38,000 points
303 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, 2022 in Others by Aditya
• 7,680 points
714 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, 2022 in Others by Aditya
• 7,680 points
7,179 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP