Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 135359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:46:41+00:00 2026-05-11T06:46:41+00:00

Is it time()? Is it time().substr(microtime(), 2, 2)? Is it time().substr(microtime(), 2, 3)? Kind

  • 0

Is it time()? Is it time().substr(microtime(), 2, 2)? Is it time().substr(microtime(), 2, 3)?

Kind of lost with the following snippet.

function updateClock ( ) {     var timeStamp = <?php echo time().substr(microtime(), 2, 2);?>;     var currentTime = new Date ( );     currentTime.setTime( timeStamp );      ...     ... } 

My goal is to use server time and start ticking from there on client browser window. The code above either returns the current client computer time or sometime in 1973. I guess I’m not getting the right time stamp format for setTime()?

Thanks!

  • 1000

I tried that but the web page still shows my local time after I upload the js.php (rendering the javascript code) to my server. My server is approx 12 hours different in time from me. My guess is that does php takes client side time into account running time() ? I mean browsers do send request time to apache right?

I copied the time() * 1000 returned value from the web page run on my server and pasted it into a local page:

<script type='text/javascript'>  var d = new Date(); d.setTime(1233760568000); document.write(d);  </script> 

And it’s indeed my local time. Thus the guess.

Is there anyway to specify time zone for time()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:46:41+00:00Added an answer on May 11, 2026 at 6:46 am

    Date.setTime expects the number of milliseconds since 1970-1-1. php’s time function yields the number of seconds since 1970-1-1. Therefore, you can just use

    var TimeStamp = <?php echo time()*1000;?> 

    Due to latency issues (the browsers needs to load the whole page before starting JavaScript), the time will usually drift one or a couple of seconds though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following: var date = new Date(parseInt(jsonDate.substr(6))); I get: Mon Feb 22 1993
This is the crucial code: var ajaxCallTimeoutID = null; $(document).ready(function() { $(input[id^='question']).live('keyup',function(ev){ id=this.id.substr(8); if
I've discovered that any time I do the following: echo '<a href=http:// title=bla>huzzah</a>'; I
Each time I use Merge() I have the following: 'Cannot implicitly convert type 'void'
I'm trying to write an elegant function in R to calculate the elapsed time
Warning: substr_count() [function.substr-count]: Empty substring. I get this message when calling the function browsertest.
I'm generating a 5 letter uniqid in PHP this way: $id = substr(uniqid(),0,5); And
this is my first time really using this site. I'm relatively new to using
select to_timestamp(trunc(state_date) || ' ' || substr(state_time,1,12),'DD-MM-YYYY HH24:MI:SS:FF3') from state_log above statement giving error
Time is confusing... How can one calculate the time elapsed from PM to AM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.