SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast LudicrousSpeed's Avatar
    Join Date
    Feb 2003
    Location
    Chicago
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting "3 June 2003" to "2003-06-03"

    I'm getting confused by the PHP Manual's entry for the date() function. I'm reading the "3 June 2003" format from a text file and converting it to the "2003-06-03" format for storage in a MySQL DB. Can anyone point me in the right direction? My biggest problem is converting "June" to "06"

  2. #2
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Convert it to a unix timestamp first with strtotime(), then use date()
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  3. #3
    SitePoint Enthusiast LudicrousSpeed's Avatar
    Join Date
    Feb 2003
    Location
    Chicago
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anode
    Convert it to a unix timestamp first with strtotime(), then use date()
    Thanks anode! I didn't think I could use strtotime() since I wasn't dealing with hours/minutes/etc. This is how I did it:

    Code:
      $newdate = date("Y-m-d", strtotime($olddate));

  4. #4
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad you got it working. You'd be amazed at some of the stuff strtotime can work with; take a look at this.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  5. #5
    SitePoint Enthusiast LudicrousSpeed's Avatar
    Join Date
    Feb 2003
    Location
    Chicago
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anode
    Glad you got it working. You'd be amazed at some of the stuff strtotime can work with; take a look at this.
    My head is spinning!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •