maxlibin Posted May 2, 2013 Share Posted May 2, 2013 i have a string like this "20 Dec, 2011", is there a way find out which day of the week is this? Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 2, 2013 Share Posted May 2, 2013 (edited) Yes. What day of week value are you wanting? Mon - Sun or 1 - 7? You would want to use date() along with strtotime(). After testing it looks like strtotime() can't use that string format as it is. You'll need to remove the comma. $date_string = "20 Dec 2013"; //Convert to timestamp $date_timestamp = strtotime(str_replace(',', '', $date_string)); //Output day of week string echo date('D', $date_timestamp); //Output: Friday //Output day of week number echo date('N', $date_timestamp); //Output: 5 Edited May 2, 2013 by Psycho Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 2, 2013 Share Posted May 2, 2013 (edited) var_dump(date('l', strtotime('20 Dec, 2011'))); // "Friday" Or, what Psycho said. Edited May 2, 2013 by DaveyK Quote Link to comment Share on other sites More sharing options...
maxlibin Posted May 2, 2013 Author Share Posted May 2, 2013 thanks guy, appreciated. Quote Link to comment 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.