Perad Posted August 17, 2007 Share Posted August 17, 2007 I was just wondering how I would get the day of the week from the string "12/07/07". Quote Link to comment https://forums.phpfreaks.com/topic/65389-get-day-from-date/ Share on other sites More sharing options...
hostfreak Posted August 17, 2007 Share Posted August 17, 2007 http://www.php.net/date <?php //php date() function with "l (lowercase 'L')" format character echo date('l', '12/07/07'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/65389-get-day-from-date/#findComment-326530 Share on other sites More sharing options...
Barand Posted August 17, 2007 Share Posted August 17, 2007 if that is m/d/y <?php $dt = '07/12/07'; echo date('D', strtotime($dt)); /** * for d/m/y */ list($d, $m, $y) = explode('/', $dt); echo date('D', strtotime("$m/$d/$y")); ?> see www.php.net/date Quote Link to comment https://forums.phpfreaks.com/topic/65389-get-day-from-date/#findComment-326531 Share on other sites More sharing options...
AndyB Posted August 17, 2007 Share Posted August 17, 2007 I was just wondering how I would get the day of the week from the string "12/07/07". As you'll see from the answers, it depends on what the highly ambiguous 12/07/07 means. Could be d/m/y; m/d/y; y/m/d; y/d/m etc. The 'standard', ISO date representation of Y-m-d (e.g. 2007-08-17 for today) is always the best bet for a database-stored date since you can also use it for ordering logically or in calculations very simply - and you can use php to re-present it in your own favourite form of date display. Quote Link to comment https://forums.phpfreaks.com/topic/65389-get-day-from-date/#findComment-326548 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.