Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Javascript time with php server time?

I have a situation where I want the server time to be displayed on a web page. At present I keep it simple and just do this

<?php 
$CTIME=date ("g:i a");
?>

This works great- except I would prefer it if it updated by itself without the need to refresh the page. I was thinking perhaps there is a way I can set the javascript time function with the time from a php script- but I've got no idea as to how I could go about doing this.

Perhaps I'm thinking about this wrong... maybe there is another solutions I'm not thinking of, Any ideas ??

like image 769
Alex Avatar asked Feb 23 '23 22:02

Alex


1 Answers

Here is a jQuery plugin for displaying a clock:

http://plugins.jquery.com/project/jqClock

Just initialize it using the time coming back from the server. It automatically updates every second on the client side.

like image 155
AJ. Avatar answered Mar 03 '23 14:03

AJ.