Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    New Coder
    Join Date
    Sep 2003
    Location
    Cardboard Box
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers - thats exactly what I did, but used the split function instead of explode.

    Thanks very much


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •