简体   繁体   English

PHP页面加载和实时变量

[英]PHP Page Load & Real-Time Variables

I am trying to get date data from a php script to the html where it displays the current time of when the page was loaded initially. 我正在尝试将日期数据从php脚本获取到html,以便在其中显示页面初始加载时的当前时间。 And the current time updated in real-time. 并且当前时间是实时更新的。

I have been able to get the current time using the 我已经能够使用

date_default_timezone_set('Europe/London');
echo date('m/d/Y h:i:s a', time());  ... 

But I cant find what the function is to get the time that the webpage was opened? 但是我找不到打开网页时间的功能是什么?

Any help please. 请帮忙。 Okay I made a mistake and got it switched. 好吧,我犯了一个错误,并把它切换了。 I have the time of page load and now I need the current time in real-time retrieved. 我有页面加载的时间,现在我需要实时获取当前时间。

No worries guys, thanks for helping me on the first bit I am gonna go try and get the real-time thingy myself :) 不用担心,感谢您在第一时间帮助我,尝试自己获取实时的东西:)

date('m/d/Y h:i:s a', time()) will be the time you generated the page. date('m/d/Y h:i:s a', time())将是您生成页面的时间。

For updating it real-time, you will need to use some client side code, as PHP only runs on the server-side. 为了实时更新它,您将需要使用一些客户端代码,因为PHP仅在服务器端运行。

For the real-time clock, I would suggest you to look at the JQuery library for JavaScript . 对于实时时钟,我建议您查看JavaScriptJQuery库。

http://jquery.com/ http://jquery.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM