Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-08-2003, 02:38 PM   PM User | #1
holty
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 262
Thanks: 0
Thanked 0 Times in 0 Posts
holty is an unknown quantity at this point
Date Splitting Help!

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
holty is offline   Reply With Quote
Old 09-08-2003, 04:21 PM   PM User | #2
lil_sarah
New Coder

 
Join Date: Sep 2003
Location: Cardboard Box
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
lil_sarah is an unknown quantity at this point
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.

PHP Code:
$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
lil_sarah is offline   Reply With Quote
Old 09-08-2003, 08:02 PM   PM User | #3
holty
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 262
Thanks: 0
Thanked 0 Times in 0 Posts
holty is an unknown quantity at this point
Cheers - thats exactly what I did, but used the split function instead of explode.

Thanks very much
holty is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 AM.


Advertisement
Log in to turn off these ads.