RSS

Displaying The Time or Date In PHP

Wed, Oct 1, 2008

PHP

Clock Time

Displaying the time or date can be very important, depending on what sort of script you have. For example, if you have a forum script you will need a date stamp on it for your users. Displaying the time or date is also very easy in PHP, and there are lots of different ways of displaying the date.

The first way, is the best in my opinion. Use the code below to show something like Wednesday 1st of October 2008 10:28:47 PM

echo date('l jS \of F Y h:i:s A');

The next, will simply show the day.

echo date("l");

The next will show the time like this 22 34

echo date('G i');

And there are millions of combinations for this… Have a look at this page and it explains everything in detail. These are just a few examples.

Rating: 10.0/10 (2 votes cast)
Share and Enjoy:
  • Digg
  • Google
  • Technorati
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Furl
  • Live
  • Reddit
  • Spurl

  • Subscribe
    • XML
    • Google Reader or Homepage
    • Add to My Yahoo!
    • Subscribe with Bloglines
    • Subscribe in NewsGator Online
    • BittyBrowser
    • Add to My AOL
    • Convert RSS to PDF
    • Subscribe in Rojo
    • Subscribe in FeedLounge
    • Subscribe with Pluck RSS reader
    • Solosub
    • MultiRSS
    • R|Mail
    • Rss fwd
    • Blogarithm
    • Eskobo
    • gritwire
    • BotABlog
    • Simpify!
    • Add to Technorati Favorites!
    • Add to netvibes
    • Add this site to your Protopage
    • Subscribe in NewsAlloy
    • Subscribe in myEarthlink
    • Add to your phone
    • Get RSS Buttons

, , , ,



This post was written by:

admin - who has written 41 posts on Unreal Media.


Contact the author

3 Comments For This Post

  1. Jay Says:

    A lot of times, a UNIX timestamp* is used to store a date, such as the date that a comment was posted. This time stamp can be generated using the time() function. You can convert the timestamp using the date() function above. Here’s an example:

    echo date(’l jS \of F Y h:i:s A’,'1198609200′);

    Normally, when you use the date function without the optional timestamp parameter, it defaults to the current output of time(). But if you include it, it will format the timestamp you provide.

    *(A UNIX timestamp is simple. It’s the number of seconds since Jan 01 1970)

    Rating: 0.0/5 (0 votes cast)
  2. Jay Says:

    There appears to be an error in my above code. It looks normal, but when copied and pasted into wordpad, the (’) are actually (`). Maybe the below code will get submitted correctly.

    echo date(”l jS \of F Y h:i:s A”,”1198609200″);

    Rating: 0.0/5 (0 votes cast)
  3. Jim Spence Says:

    Sunday In searching for sites related to web hosting and specifically unix web hosting uk, your site came up.

    Rating: 0.0/5 (0 votes cast)

Leave a Reply