Vermillion Posted March 13, 2010 Share Posted March 13, 2010 Suppose I have the following DateTime string. 20100312122636 How can I determine what day is it based on it? I want to know what day (Sunday, Monday, Tuesday...) is based on that string, but I can't figure a way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/195137-determing-the-day-from-a-datetime-string/ Share on other sites More sharing options...
salathe Posted March 13, 2010 Share Posted March 13, 2010 You'll need to convert that into something usable by PHP's date funtions and from there it is easy to get the day of the week. For example (the following could be mushed onto one line, it is split up for ease of understanding): $date = '20100312122636'; // Grab date parts $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); // Get the UNIX timestamp for the date $timestamp = gmmktime(0, 0, 0, $month, $day, $year); // Print the day of week echo date('l', $timestamp); Quote Link to comment https://forums.phpfreaks.com/topic/195137-determing-the-day-from-a-datetime-string/#findComment-1025684 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.