...

View Full Version : Date Splitting Help!



holty
09-08-2003, 02:38 PM
Hi all,

I have a date that looks like: Sun Aug 17 14:34:39 BST 2003 thats held in a variable named $date.

How can I split it to look like:

Aug 17 2003?


Thanks

lil_sarah
09-08-2003, 04:21 PM
You could explode the variable into an array using a space as the separator, and then recreate a variable with the 2nd, 3rd and 6th parts of the array

eg.



$date = "Sun Aug 17 14:34:39 BST 2003";
$date_split = explode (" ", $date);

$new_date = $date_split[1]." ".$date_split[2]." ".$date_split[5];


possibly not the cleanest way to do it but a quick fix

hth

holty
09-08-2003, 08:02 PM
Cheers - thats exactly what I did, but used the split function instead of explode.

Thanks very much



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum