August 12, 2007
I’m not proud of this
find more posts in: php…but I didn’t have much of a choice:
function parse_date_from_string($string=""){ $month_names = array("", "January","February","March","April","May","June","July","August","September","October","November","December"); $regex = "/(\d{1,2})[-|\/|\.](\d{1,2})[-|\/|\.](\d{2}|\d{4})/"; $date = array(); if(preg_match($regex, $string, $matches)){ $month = preg_replace("/^0/", "", $matches[1]); $date['month'] = $month_names[$month]; $date['day'] = $matches[2]; if(strlen($matches[3]) == 2) $matches[3] = "20" . $matches[3]; $date['year'] = $matches[3]; $date['string'] = trim(preg_replace($regex, "", $string)); } return $date; }
1 Response
Leave a Reply
My name is Joey Nelson. I'm a web developer living in Portland, OR. I'm married to an awesome lady and we have two weird little pugs. I do a weekly comedy podcast and make dumb songs with this guy Ben. I don't post to this blog very often, and very few people actually read it. If you'd like to find out more about my fascinating life, check this stuff out:
Stuff
Visit my sites
Visit my friends
Latest posts
Categories
- art
- audio
- baseball
- bikes
- books
- browsers
- complaints
- crime
- death
- dumb things
- energy
- environment
- family
- friends
- gadgets
- internet
- life
- los angeles
- marriage
- movies
- music
- mysql
- new york
- os x
- pasadena
- photos
- php
- plugins
- podcasting
- politics
- portland
- pugs
- rss
- ruby
- splideo
- subversion
- ubuntu
- video
- watir
- wordpress
- work
HOW COULD YOU JOEY, HOW COULD YOU