#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,689
    Rep Power
    171

    Check string format and convert.


    Hi;

    $_GET['entry'] is sent to a page and it could be different formats.

    How can I check

    If the format of $_GET['entry'] is like 'yyyy-mm-dd'

    Then change the format like this:

    date(d/m/y', strtotime($_GET['entry']))?

    Thanks
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    Regex to validate the format and grab the pieces (explode() can do that part too), checkdate() to validate the date unless you don't mind over- and underflows with numbers, then the reformatting which you've already answered but could also be done with mktime() since you have the pieces.

IMN logo majestic logo threadwatch logo seochat tools logo