SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing characters....

    Hi there all,
    Short one as I'm knackered from too much coding!

    I have a date stored in a variable ($datehold) as "21/09/2001" and I need to truncate it so that it reads "2109" (ie day of month and month with no spaces or slashes).

    How would I go about this in PHP?

    Thanks in advance!

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this
    Code:
    list ($a,$b,$c) = explode('/',$datehold);
    
    echo $ab.$b;

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it'd be easier if you just did this:
    PHP Code:
    $datehold date("dm"); 
    that'd format the date as 2209 (as it's september 22nd here now.)
    or you could just make a new variable with the above code and use that.
    Last edited by Defender1; Sep 21, 2001 at 22:40.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks folks!

    Defender, I'll probably use that later on as I can see it being quite useful, but the date I have isn't actually today's date. Good tip though, thanks!

    Paul S, spot on man! Thank you.



Bookmarks

Posting Permissions

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