Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

php - Datetime To Unix timestamp

Is there anyone sitting on a PHP function to convert a date of format 0000-00-00 00:00:00(datetimesql) to unix timestamp?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To do this in PHP 5.2 you can do this:

$datetime = new DateTime();
echo $datetime->format('U');

A newer way to do this as of PHP 5.3 is:

$datetime = new DateTime();
echo $datetime->getTimestamp();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...