RE: [PHP] how to get day of week?

From: Date: Tue, 22 Aug 2000 20:57:47 +0000
Subject: RE: [PHP] how to get day of week?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13023@lists.php.net to get a copy of this message
http://www.mysql.com/documentation/mysql/commented/manual.php?section=Date_a nd_time_functions (that's all one line, of course, in case your mail client wrapped it.) (The "%a", "%w", and "%W" format specifiers will likely be of particular interest.)
Another way can be even more pretty : ) From MySQL Online Documentation : DAYOFWEEK(date) Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard. mysql> select DAYOFWEEK('1998-02-03');
        -> 3
-- <?php /* connection and that greasy stuff here */ $day_of_week = array(1 => "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $sql = "SELECT DAYOFWEEK(date_field_name_here) AS DAY FROM table_name"; $result = mysql_query($sql, $conn); $day = mysql_result($result, 0, 0); echo "The day of the week is : " . $day_of_week[$day] . "<BR>\n"; ?> Regards, Joao

« previous php.general (#13023) next »