If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Server Time

Hello, I am quite new here so I am not sure if I am on the right section.
I would like to place a server time clock inside a wordpress widget.
Now I came up with this code, its all included with the style and I would like to keep this style but this clock doesn't show the server time but the client time.

You will need to sub the local timezone of your server here date_default_timezone_set('America/Los_Angeles');

What you then have is a date object returned by the server, set on the clients machine as milliseconds

the stringTime will be a string time representation already formatted

You will need to have other time functions if you want to have the time of this object advanced, because this is in milliseconds, you can incorporate other functions that return milliseconds so you can calculate what you need.

The JavaScript Date() object understands many different time formats, string dates such as RFC dats and ISO dates and times, milliseconds and d/m/y h:m:s formats.

Avoid using setTimeout callbacks, they take time to set up and consume time, use the setInterval, it only needs to be set once and it will keep on calling the function until page is shut down or navigated away from.

--> JavaScript Frameworks like JQuery, Angular, Node <--
... and please remember to wrap code with forum BBCode tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...