I'm trying to make a date converter and I can't figure out how to parse the code that we are going to use (122301 for todays date) and have it display December 23, 2001. Any help will be greatly appreciated.

    $raw_date = '122301';
    $formatted_date = Date('F d,Y', strtotime(preg_replace('/(\d{2})(\d{2})(\d{2})/', '\3-\1-\2',$raw_date)));

      • [deleted]

      Elegant, but this is more than twice as fast (under windows, can't check un*x right now)

      $raw_date = '122301';
      echo Date('F d,Y', mktime(0, 0, 0, substr($raw_date,0,2),substr($raw_date,2,2),substr($raw_date,4,2)));

        Write a Reply...