SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: convert time

  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    convert time

    How can i convert this

    20080506

    to
    6th May 2008

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    This should do it.

    PHP Code:
    <?php

    //--> Create Date Function.
    function formatDate$sDate )
    {
        
    $sDateFormat 'dS M Y';
        return 
    date$sDateFormat mktime(null,null,null,substr($sDate,4,2),substr($sDate,6,2),substr($sDate,0,4)) );
    }

    print(
    formatDate('20080506'));
    //--> Outputs 06th May 2008

    ?>
    Good luck, SilverB.

  3. #3
    SitePoint Addict
    Join Date
    Jan 2008
    Posts
    326
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to fine-tune your date format look at

    http://us2.php.net/date


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
  •