August 12, 2007
I’m not proud of this 1
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 Raleigh, NC. I'm married to an awesome lady and we have an awesome one year old son. If you'd like to find out more about my fascinating life, check this stuff out:
Track me
Visit my sites
Other stuff
Latest posts
- Google ASCII Art Easter Egg
- Is it so crazy that someone would play VATFUL?
- Now that’s a quesadilla
- Automatically playing audio with HTML5 and Javascript (even on the iPad)
- Prevent console.log() errors
- Tumblin’
- omgtru updates and iPhone web app lessons learned
- Really?
- Easy form hints: HTML5 input placeholders
- Anthem Type
Categories
- apple
- art
- audio
- baseball
- bikes
- books
- browsers
- comedy
- complaints
- crime
- death
- dumb things
- energy
- environment
- family
- fonts
- food
- friends
- gadgets
- games
- henry
- html
- internet
- ipad
- iphone
- itunes
- javascript
- jquery
- life
- los angeles
- marriage
- movies
- msgblorb
- music
- mysql
- new york
- omgtru
- os x
- pasadena
- photos
- php
- plugins
- podcasting
- politics
- portland
- pugs
- rss
- ruby
- splideo
- subversion
- ubuntu
- Uncategorized
- video
- watir
- wordpress
- work
HOW COULD YOU JOEY, HOW COULD YOU