Regex help

Discussion in 'PHP' started by ttyler333, Mar 15, 2012.

  1. #1
    I am trying to preg_match this " Expiration Date: 23-may-2012" except the "23-may-2012" could actually be returned in a bunch of ways.. Anyways any help would be great.
     
    ttyler333, Mar 15, 2012 IP
  2. ttyler333

    ttyler333 Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    This is the code i am using to attempt to fetch. preg_match('/^Expiration Date: [A-z0-9_]/', $where, $output);
     
    ttyler333, Mar 15, 2012 IP
  3. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #3
    This should do it, no need for regular expression (no matter what format the date is in):

    
    <?php
    $string = str_replace('Expiration Date:', '', 'Expiration Date: 23-may-2012');
    
    echo date("Y-m-d H:i:s", strtotime($string));
    
    
    PHP:
     
    ThePHPMaster, Mar 17, 2012 IP