SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)

    Convert string to date by passing pattern?

    Having trouble researching this one or coming up with my own solution. I need to be able to pass a date/time pattern that will then used to convert a string to DateTime.

    Code PHP:
    $string = '20130408164312'; // yyyymmddhhmmss
    $string2 = '2013-04-08 16:43:12'

    I should be able to pass both of those strings to a function, along with some sort of pattern string and be able to return a DateTime object. I'm trying to make this completely versatile. Ideas/functions you've already come across?

  2. #2

  3. #3
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    Ya, I was just coming back to paste that myself.. My googling skills weren't on par today I suppose. Thanks.


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
  •