Anzeo Posted July 7, 2007 Share Posted July 7, 2007 Hi all, finally back to coding. I've advanced quite a bit with my current project, but the time has come again I can't code my way any further. I'm currently working on a (simple) calendar system which allows registered users to add an event to the calendar. The table EVENT stores info about the author, date and description of the event. I then managed to output a list in which only events of this year are showed and are grouped together by months. And now I only need one more thing to complete the script. I want to output for every event on which day of the week it occurs (monday - sunday). I've looked around for tutorials but haven't found a basic one. Does anyone know how to accomplish this? Many thanks in advance! Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/ Share on other sites More sharing options...
Jewbilee Posted July 7, 2007 Share Posted July 7, 2007 if you know the number month, the number day, and the number year: echo date("l", mktime(0, 0, 0, $month, $day, year)); Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-291940 Share on other sites More sharing options...
AndyB Posted July 7, 2007 Share Posted July 7, 2007 Just to add to that ... http://www.php.net/manual/en/function.date.php http://www.php.net/manual/en/function.mktime.php Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-291943 Share on other sites More sharing options...
Anzeo Posted July 7, 2007 Author Share Posted July 7, 2007 Works great, thanks a lot! Is their a quick way to translate the result to dutch? Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-291963 Share on other sites More sharing options...
AndyB Posted July 7, 2007 Share Posted July 7, 2007 http://www.php.net/manual/en/function.setlocale.php - the very first example Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-291988 Share on other sites More sharing options...
Anzeo Posted July 7, 2007 Author Share Posted July 7, 2007 The setlocal doesn't seem to be working. I assume I'll have to use a switch or something like that to translate 'manually' ? I read somewhere that the language file has to be installed on the server in order for setlocal to be working? Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-291996 Share on other sites More sharing options...
Barand Posted July 7, 2007 Share Posted July 7, 2007 date('w') returns 0-6 (sun-sat) so you could use use an array of daynames if all else fails Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-292026 Share on other sites More sharing options...
Anzeo Posted July 7, 2007 Author Share Posted July 7, 2007 But when using the date function, I can't use a given specified date as the argument or can I? Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-292034 Share on other sites More sharing options...
Barand Posted July 7, 2007 Share Posted July 7, 2007 You have already seen that you can do that in an earlier post. I was just suggesting "w" instead of "l" and using an array such as this (only translated into Dutch equivalents) <?php $days = array('Sunday', 'Monday', 'Tuesday','Wednesday', 'Thursday', 'Friday', 'Saturday'); $dow = date('w', strtotime('2007-07-07')); echo $days[$dow]; // Saturday ?> Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-292039 Share on other sites More sharing options...
Anzeo Posted July 7, 2007 Author Share Posted July 7, 2007 Thanks everyone got it working ^^! I'm going to study more on the date functions . Link to comment https://forums.phpfreaks.com/topic/58840-solved-how-to-calculate-the-day-of-the-week-by-a-given-date/#findComment-292060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.