Results 1 to 5 of 5
  1. #1
    Full Member dak142's Avatar
    Join Date
    January 18th, 2005
    Posts
    386
    I am looking to format "20041213" into a more friendly to the eye format. I have been trying to find a way to do it in PHP and have come up short. Any suggestions?

  2. #2
    Affiliate Manager
    Join Date
    January 18th, 2005
    Posts
    1,056
    David,

    Is this date already in a database and you want to convert it? Sorry, not clear about what you are trying to do.

    To get current date:

    <pre class="ip-ubbcode-code-pre">
    &lt;?
    $today = date("m-d-y");
    echo "$today";
    ?&gt;
    </pre>

  3. #3
    Affiliate Manager
    Join Date
    January 18th, 2005
    Posts
    1,056
    Also, in case you want to convert a date already in your database:

    <pre class="ip-ubbcode-code-pre">
    &lt;?
    $date = strtotime("20041213");
    $newdate = date("m-d-y","$date");
    echo "$newdate";
    ?&gt;
    </pre>

  4. #4
    Just Lurking
    Join Date
    January 18th, 2005
    Posts
    1,263
    There's also strftime(): http://www.php.net/manual/en/function.strftime.php

    <pre class="ip-ubbcode-code-pre">echo strftime('%B %e, %Y'); // like: January 1, 2004</pre>Lot's of other options.
    Lead, Follow or Get Out of the Way!

  5. #5
    Full Member dak142's Avatar
    Join Date
    January 18th, 2005
    Posts
    386
    Thank you all, that is just what I needed. Sometimes the help I get around here is so good I feel like I should be paying for it!

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP question - include(file.php) with variables
    By teezone in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: September 4th, 2009, 04:54 PM
  2. Event Date vs. Posting Date
    By Rodski in forum Commission Junction - CJ
    Replies: 4
    Last Post: November 18th, 2005, 11:59 AM
  3. asinsearch.format and grid list format
    By speedcreed in forum Cusimano.com Scripts
    Replies: 1
    Last Post: August 21st, 2003, 09:50 AM

Posting Permissions

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