I have a date field on my database. the date format as following.
Im using the format as
So my question is there a way that i can display this date in RFC-822 format using php? or do i need to start saving the date in RFC-822 format from now on? Thanks in advance.
asked Jun 17, 2013 at 6:50
2 Neither. From now on you have to start using format supplied by database. And then convert at output to whatever format required - not limited to a single one but whatever format is demanded by destination. answered Jun 17, 2013 at 6:58
Your Common SenseYour Common Sense 156k39 gold badges208 silver badges331 bronze badges 2 Using the following syntax, you can display current time in RFC822 Format.
answered Jun 17, 2013 at 6:53
DevZer0DevZer0 13.3k6 gold badges25 silver badges51 bronze badges 0 None of the other answers worked for me, so this is what worked... to take a date in PHP and output it in RFC822:
Hope that helps others. answered Apr 25, 2017 at 15:16
Dan GoodspeedDan Goodspeed 3,4324 gold badges24 silver badges35 bronze badges 2 As was pointed out your best bet is to change the way you are storing your dates to something other then a string. But to solve the immediate need you can utilize use strtotime, date and the DATE_RFC822 constant to get you what you are looking for.
See First example on php date documentation answered Jun 17, 2013 at 6:55
OrangepillOrangepill 24.4k3 gold badges40 silver badges63 bronze badges As @ashleedawg and others mentioned in some comments the simplest solution that works:
Mind the "H" and the "O" ;) answered Nov 24, 2020 at 10:59
romekromek 5551 gold badge5 silver badges13 bronze badges date_format(date(your database field), '%D, %j %M %t') and what type of format you want just see the link date and time format for Mysql answered Jun 17, 2013 at 7:33
You can save it as TimeStamp in database and show it RFC822 format
answered Dec 23, 2016 at 18:51
YuseferiYuseferi 7,15711 gold badges61 silver badges96 bronze badges 1 This is the only solution that worked for me:
Other examples above that didn't work include using the DATE_RFC822 format specifier, which puts out a 2-digit year, instead of 4 digits. Then the other suggestion to use G:i:s for time doesn't work because G specifies no leading zeroes, so you'll get 2:00:00 instead of 02:00:00. answered Jul 6, 2020 at 2:01
don't use T at the end but an "O", it works for me answered Aug 11, 2021 at 14:45
1 If you want to date format something in PHP for RFC-822 , then just do this...
Source: PHP.net: DateFormat But, as other stated, you don't want to store this in your database! However, you'll need to use
answered Dec 19, 2021 at 2:07
HoldOffHungerHoldOffHunger 16.7k8 gold badges92 silver badges121 bronze badges 1 |