Re: Reverse of date("w")

From: Date: Tue, 19 Sep 2006 15:02:53 +0000
Subject: Re: Reverse of date("w")
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-241935@lists.php.net to get a copy of this message
Kevin Murphy wrote:
Not really. If it were always "today" that would work, but in this case, I was thinking of storing a day of the week in a database ("3"), and then display the info based on that digit. So assuming that the number was in fact 3, then: echo date("D","3"); Would return "Wed". Is there any function like that? Oh, and it has to run on PHP 4.
Any reason you wouldn't write it yourself? <?php function getDayFromInteger($integer) { $days = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); if (isset($days[$integer])) {
      return $days[$integer];
} return false; } ?>
No reason..... and its what I was planning on. I just was hoping that there was a pre-built function that I was just not seeing. Your solution above is probably the best one. Thanks. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326

« previous php.general (#241935) next »