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
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts

    How to remove leading 0 from date

    I would like to remove the leading 0 from the displayed date.
    e.g.
    I have:
    PHP Code:
    $date=trim(date(' dS F Y')); 
    At the moment I get: $date returns 03rd April 2013 (today's date)
    I want it to return 3rd April 2013

    Can somebody advise me how to do it.

    Thanks.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    don't put that zero in the first place. prolly simpler
    PHP Code:
    $date=date(' jS F Y'); 

    -------------------------------------------------------------------------------
    "Real Programmers can write assembly code in any language" - Larry Wall

  • Users who have thanked patryk for this post:

    countrydj (04-03-2013)

  • #3
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Hi patryk..

    I don't like being kept waiting... (lol)
    Thank you very much for the quickest reply that I've ever had.

    I can't believe that the answer was that simple.
    It is now in my global.php file so it will be available for all my other pages.

    Thanks again.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club


  •  

    Posting Permissions

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