SitePoint Sponsor |
|
User Tag List
Results 1 to 14 of 14
Thread: Changing Date Format, Possible?
-
May 29, 2003, 18:08 #1
- Join Date
- Sep 2002
- Location
- Los Angeles
- Posts
- 1,709
- Mentioned
- 5 Post(s)
- Tagged
- 0 Thread(s)
Changing Date Format, Possible?
Currently I offer the customer to view an upcoming calendar. This is done by selecting the desired date from a drop menu. Seen here:
PHP Code:while ($list = mysql_fetch_array($soups)) {
$date = $list["Day"];
echo("<option value='$date'>$date</option>");
After putting some thought into it, I would need to disect the value and piece it together in a new order with 3 variables, right? I just can't seem to get it to work.
Thanks guys!TAKE A WALK OUTSIDE YOUR MIND.
-
May 29, 2003, 18:17 #2
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
date
(PHP 3, PHP 4 )
date -- Format a local time/date
Description
string date ( string format [, int timestamp])
Returns a string formatted according to the given format string using the given integer timestamp or the current local time if no timestamp is given.
-
May 29, 2003, 18:20 #3
- Join Date
- Mar 2002
- Location
- Cincinnati, Ohio
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Im not sure if this is what you were looking for, but here's some code that might help:
PHP Code:<?php
while ($list = mysql_fetch_array($soups)) {
$date = $list["Day"];
list ($year, $month, $day) = split ('[/.-]', $date);
if($month==01) {
$month = "January";
} elseif($month==02) {
$month = "Febuary";
} elseif($month==03) {
$month = "March";
} elseif($month==04) {
$month = "April";
} elseif($month==05) {
$month = "May";
} elseif($month==06) {
$month = "June";
} elseif($month==07) {
$month = "July";
} elseif($month==08) {
$month = "August";
} elseif($month==09) {
$month = "September";
} elseif($month==10) {
$month = "October";
} elseif($month==11) {
$month = "November";
} elseif($month==12) {
$month = "December";
}
$date = $month.' '.$day.', '.$year;
echo("<option value='$date'>$date</option>" );
?>
-
May 29, 2003, 18:20 #4
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
BTW, why are customers confused by YYYY-MM-DD?
That's the ISO standard for dates
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
-
May 29, 2003, 18:20 #5
- Join Date
- Sep 2002
- Location
- Los Angeles
- Posts
- 1,709
- Mentioned
- 5 Post(s)
- Tagged
- 0 Thread(s)
I read that before, and it didn't really help. Could you please explain?
TAKE A WALK OUTSIDE YOUR MIND.
-
May 29, 2003, 18:25 #6
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Example:
echo "<option value='$date'>" .date("l F j Y", $date) ."</option>";
should print out
<option value="2003-05-30">Friday May 30 2003</option>
Edit: Forgot... $date can't be a string, must be a timestamp...
Correct code
list($y, $m, $d) = explode("-", $date);
echo "<option value='$date'>" .date("l F j Y", mktime(0, 0, 0, $m, $d, $y)) ."</option>";Last edited by jofa; May 29, 2003 at 19:29.
-
May 29, 2003, 18:47 #7
- Join Date
- Mar 2002
- Location
- Cincinnati, Ohio
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Learn something new every day. I didn't know you could do that jofa? Thanks for that!
-
May 29, 2003, 18:50 #8
- Join Date
- Dec 2002
- Location
- Canada
- Posts
- 2,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I live in Canada, and doing a lot of work in BOTH USA and Canada... I find it VERY annoying to distinguish whether the date is MM/DD or DD/MM... as they are in different orders in the different countries... I wish everyone would just use naming in the date... heh
AskItOnline.com - Need answers? Ask it online.
Create powerful online surveys with ease in minutes!
Sign up for your FREE account today!
Follow us on Twitter
-
May 29, 2003, 19:33 #9
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by WhSox21
Comment: All those if...elseif? Why not use switch?
-
May 29, 2003, 19:37 #10
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by KandieMan101
-
May 29, 2003, 19:49 #11
- Join Date
- Jan 2003
- Location
- Calgary, Canada
- Posts
- 2,063
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:date('l F j Y', strtotime($date));
Who walks the stairs without a care
It shoots so high in the sky.
Bounce up and down just like a clown.
Everyone knows its Slinky.
-
May 29, 2003, 19:49 #12
- Join Date
- Dec 2002
- Location
- Canada
- Posts
- 2,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by jofa
AskItOnline.com - Need answers? Ask it online.
Create powerful online surveys with ease in minutes!
Sign up for your FREE account today!
Follow us on Twitter
-
May 30, 2003, 05:53 #13
- Join Date
- Sep 2002
- Location
- Los Angeles
- Posts
- 1,709
- Mentioned
- 5 Post(s)
- Tagged
- 0 Thread(s)
Thanks guys! Worked perfectly.
TAKE A WALK OUTSIDE YOUR MIND.
-
May 30, 2003, 12:37 #14
- Join Date
- Dec 2002
- Location
- Canada
- Posts
- 2,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Great to hear!
AskItOnline.com - Need answers? Ask it online.
Create powerful online surveys with ease in minutes!
Sign up for your FREE account today!
Follow us on Twitter
Bookmarks