Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我真的很需要你的帮助。我有这个 date() 格式:
<?php date("j. n. Y G:i:s"); ?>
但稍后在代码中我需要将其转换为 time() (使用 strtotime),但它失败了。我不知道有什么功能可以做到这一点。我的问题来了——你知道任何功能吗?或者你至少知道如何转换它?我将非常感激。
该date()函数接受第二个参数,一个 UNIX 时间戳,与strtotime()生成的时间戳相同。在您的示例中,您没有传递date()时间戳,因此它使用time()函数的值。无需从格式化的日期字符串中解析出时间戳;你已经有了。
date()
strtotime()
time()
但稍后在代码中我需要将其转换为time()(使用 strtotime),
简单地:
echo strtotime($yourTimeString);
应该给你time()函数格式的时间戳。