#1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,007
    Rep Power
    175

    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. Confusing Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    15,924
    Rep Power
    9570
    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