简体   繁体   English

从PHP到SQL以TIMESTAMP获取客户端时间

[英]Get clients time as TIMESTAMP from PHP to SQL

I am looking to find out how I can get clients local time as the timestamp when submit is pressed on my form. 我正在寻找如何在表单上按Submit时获得本地时间作为时间戳的方法。

My server is hosted in the US and I am in Ireland, have checked if I can change the time but this isn't possible as its a shared server. 我的服务器托管在美国,而我在爱尔兰,已经检查了是否可以更改时间,但是这不能作为共享服务器。 Can anyone point in the right direction to do the above? 任何人都可以指出正确的方向进行上述操作吗?

You can set the time zone in your PHP code using the date_default_timezone_set() . 您可以使用date_default_timezone_set()在PHP代码中设置时区。 The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script. date_default_timezone_set()函数设置脚本中所有日期/时间函数使用的默认时区。 Then use the date() to generate the current date/time in PHP and insert that date/time in the database table. 然后使用date()在PHP中生成当前日期/时间,并将该日期/时间插入数据库表中。

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

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