简体   繁体   English

尝试使用strtotime将mysql时间戳转换为时间

[英]Trying to convert mysql timestamp to time using strtotime

strtotime($_SESSION['starttime']) I tried to convert the mysql time stored as $_SESSION['starttime'] of value 1422094831 but I want to convert the resulting to time using strtotime but returns no value. strtotime($_SESSION['starttime'])我尝试将存储为$ _SESSION ['starttime']的mysql时间转换为值1422094831,但我想使用strtotime将结果转换为时间,但不返回任何值。 What could be wrong? 有什么事吗

strtotime() is used to create a timestamp, not convert it to a date. strtotime()用于创建时间戳,而不是将其转换为日期。 If your session variable stores a timestamp, try using the date() function to convert it to a more readable format. 如果您的会话变量存储时间戳,请尝试使用date()函数将其转换为更具可读性的格式。

echo date("Y-m-d", $yourTimestamp); //Will print YYYY-MM-DD format date

The PHP doc will help you using the date() function correctly. PHP文档将帮助您正确使用date()函数。

If that's not what you want to do then please provide more information in your question, from what I understand you already have a timestamp. 如果这不是您想要的,请提供更多信息,据我了解,您已经有时间戳了。

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

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