[PHP] help with date formatting

2002-03-18 Thread Ryan

Hi, I'm trying to create an events page, where it shows the posted
events.  I enter data using phpmyadmin.  Currently, the ouput is like
this:


Conference in New York
2002-03-06

There is going to be a conference in New York next week.


I'm having trouble with the formatting of the date.  I'm using the type
date with the function now, so it shows the current date when I post an
event.  Here is what I would like:


Conference in New York
Wednesday, March 5th, 2002

There is going to be a conference in New York next week.


Thanks for any help.

-- 
Ryan Spangler
428 N Harmony Ln, Apt. 3
Whitewater, WI 53190
(262) 473-8392
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] help with date formatting

2002-03-18 Thread Mark Heintz PHP Mailing Lists


Since you're using phpmyadmin, I'm assuming you're using mysql.  You could
use the built-in date and time functions to do the formatting when
selecting your date field.  Check here:

http://www.mysql.com/doc/D/a/Date_and_time_functions.html

mh.

On Mon, 18 Mar 2002, Ryan wrote:

 Hi, I'm trying to create an events page, where it shows the posted
 events.  I enter data using phpmyadmin.  Currently, the ouput is like
 this:

 
 Conference in New York
 2002-03-06

 There is going to be a conference in New York next week.
 

 I'm having trouble with the formatting of the date.  I'm using the type
 date with the function now, so it shows the current date when I post an
 event.  Here is what I would like:

 
 Conference in New York
 Wednesday, March 5th, 2002

 There is going to be a conference in New York next week.
 

 Thanks for any help.

 --
 Ryan Spangler
 428 N Harmony Ln, Apt. 3
 Whitewater, WI 53190
 (262) 473-8392
 [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] help with date formatting

2002-03-18 Thread Ben Edwards

I use string manipulation on the date, basically split it into $day, $month 
and $year and use this to product formatted output.

Ben

At 17:51 18/03/2002, Ryan wrote:

Hi, I'm trying to create an events page, where it shows the posted
events.  I enter data using phpmyadmin.  Currently, the ouput is like
this:


Conference in New York
2002-03-06

There is going to be a conference in New York next week.


I'm having trouble with the formatting of the date.  I'm using the type
date with the function now, so it shows the current date when I post an
event.  Here is what I would like:


Conference in New York
Wednesday, March 5th, 2002

There is going to be a conference in New York next week.


Thanks for any help.

--
Ryan Spangler
428 N Harmony Ln, Apt. 3
Whitewater, WI 53190
(262) 473-8392
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


* Ben Edwards  +44 (0)117 9400 636 *
* Critical Site Builderhttp://www.criticaldistribution.com *
* online collaborative web authoring content management system *
* i-Contact Progressive Video  http://www.videonetwork.org *
* Smashing the Corporate image   http://www.subvertise.org *
* Bristol Indymedia   http://bristol.indymedia.org *
* Bristol's radical news http://www.bristle.org.uk *
* PGP : F0CA 42B8 D56F 28AD 169B  49F3 3056 C6DB 8538 EEF8 *




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] help with date formatting

2002-03-18 Thread mnc

On Mon, 18 Mar 2002, Ryan wrote:
 Hi, I'm trying to create an events page, where it shows the posted
 events.  I enter data using phpmyadmin.  Currently, the ouput is like
 this:
 
 2002-03-06
 
 I'm having trouble with the formatting of the date.  I'm using the type
 date with the function now, so it shows the current date when I post an
 event.  Here is what I would like:
 
 Wednesday, March 5th, 2002

I'm guessing you're fetching the date out of a MySQL table.

Use strtotime() to convert that into a timestamp, then use date() to 
convert that into the format you want. Both are well-documented in the 
manual.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] help with date formatting

2002-03-06 Thread Ryan

Hi, I'm trying to create an events page, where it shows the posted
events.  I enter data using phpmyadmin.  Currently, the ouput is like
this:


Conference in New York
2002-03-06

There is going to be a conference in New York next week.


I'm having trouble with the formatting of the date.  I'm using the type
date with the function now, so it shows the current date when I post an
event.  Here is what I would like:


Conference in New York
Wednesday, March 5th, 2002

There is going to be a conference in New York next week.


Thanks for any help.

-- 
Ryan Spangler
428 N Harmony Ln, Apt. 3
Whitewater, WI 53190
(262) 473-8392
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] help with date formatting

2002-03-06 Thread Anas Mughal

Sure, you could do something like:

   $event_month = substr($event_row[Date], 5, 2);
   $event_day   = substr($event_row[Date], 8, 2);
   $event_year  = substr($event_row[Date], 0, 4);
   $msgBody = Date:  . date(l,
mktime(0,0,0,$event_month, $event_day,
$event_year)) . ,  . date(F,
mktime(0,0,0,$event_month, $event_day, $event_year)) .
  . fancyNumber((int) $event_day) . ,  .
$event_year . \n;



function fancyNumber($num) {  
   
 // a better implementation should use '%'.   

  
 if ($num  1)

 return $num;  
 else if ($num == 1 || $num == 21 || $num == 31)  

 return $num . st;   
 else if ($num == 2 || $num == 22)

 return $num . nd;   
 else if ($num == 3 || $num == 23)

 return $num . rd;   
 else 

 return $num . th;   
}


Sorry, I forgot to change my implementation to use %.
But, you would get the idea... :)




--- Ryan [EMAIL PROTECTED] wrote:
 Hi, I'm trying to create an events page, where it
 shows the posted
 events.  I enter data using phpmyadmin.  Currently,
 the ouput is like
 this:
 


 Conference in New York
 2002-03-06
 
 There is going to be a conference in New York next
 week.


 
 I'm having trouble with the formatting of the date. 
 I'm using the type
 date with the function now, so it shows the current
 date when I post an
 event.  Here is what I would like:
 


 Conference in New York
 Wednesday, March 5th, 2002
 
 There is going to be a conference in New York next
 week.


 
 Thanks for any help.
 
 -- 
 Ryan Spangler
 428 N Harmony Ln, Apt. 3
 Whitewater, WI 53190
 (262) 473-8392
 [EMAIL PROTECTED]
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


=
Anas Mughal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Tel: 973-249-6665

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php