xcoderx Posted February 16, 2010 Share Posted February 16, 2010 hey how would i display this echo "Todays date:".date('d-m-Y'); in 8 different formats? Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/ Share on other sites More sharing options...
gizmola Posted February 16, 2010 Share Posted February 16, 2010 Well you're passing the format string 'd-m-Y' as a constant. If you instead passed that as a variable, you could allow it to output however you wanted. Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013055 Share on other sites More sharing options...
trq Posted February 16, 2010 Share Posted February 16, 2010 You realize that the first argument to date is the format you want? I'd start there. Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013056 Share on other sites More sharing options...
salathe Posted February 16, 2010 Share Posted February 16, 2010 What are the 'formats' that you want to display the date as? Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013098 Share on other sites More sharing options...
xcoderx Posted February 16, 2010 Author Share Posted February 16, 2010 something like this i meant echo "Todays date: ".date('d.m.Y'); echo "<br/>Todays Is date: ".date('dM/D/y'); echo "<br/>Todays date: ".date('F-Dd-Y'); display it in 8 different ways, anymore help? i managed 3 different formats and 5 more left Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013301 Share on other sites More sharing options...
Axeia Posted February 16, 2010 Share Posted February 16, 2010 You may want to look at the documentation which lists all the different 'letters' that get you different results. Why would you want to do this though, some kind of homework assignment? Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013314 Share on other sites More sharing options...
xcoderx Posted February 16, 2010 Author Share Posted February 16, 2010 homework :-) Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013327 Share on other sites More sharing options...
Psycho Posted February 16, 2010 Share Posted February 16, 2010 something like this i meant echo "Todays date: ".date('d.m.Y'); echo "<br/>Todays Is date: ".date('dM/D/y'); echo "<br/>Todays date: ".date('F-Dd-Y'); display it in 8 different ways, anymore help? i managed 3 different formats and 5 more left Did you test out those "formats"? The last two aren't formats that I have ever seen used. You would get something like: 16Feb/Tue/2010 or February-Tue16-2010 I *think* your instructor is wanting you to find eight formats that would be legitimately used. Think about how dates are used by people (in different countries) and by machines. Or, be lazy, and do a simple google seach for "date format". Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013330 Share on other sites More sharing options...
xcoderx Posted February 16, 2010 Author Share Posted February 16, 2010 you are right but the thing is im not getting any idea, and yeah i get it like this Todays date: 16.02.2010 Todays Is date: 16Feb/Tue/10 Todays date: February-Tue16-2010 Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013332 Share on other sites More sharing options...
Psycho Posted February 16, 2010 Share Posted February 16, 2010 Like I said, do a Google search for "date format". Google is the all knowing entity. Quote Link to comment https://forums.phpfreaks.com/topic/192242-displaying-date-in-8-different-formats/#findComment-1013350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.