SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post synchronous time

    Hi, Is it possible in PHP that my time will be synchronous ?

    PHP Code:
      $time date('g:i:s a');

     echo 
    "Time is exactly: $time"
    I need to refresh the page first in order my time will be updated,but what i want is to make my time synchronous, is this possible in php?

    Thank you in advance.

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,077
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    No. PHP is only generated once the page loads, after that you can't do anything with it. To just show the time, you might want to look at javascript.

    Here is a nice tutorial to get you started: http://www.elated.com/articles/creat...ascript-clock/

    (technically I suppose you could do it with AJAX, but that's waaaay overkill for this particular problem)
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank your for this ScallioXTX


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
  •