Phalcon中提供了 Phalcon\Date
日期助手类,让你更方便的处理日期数据。
<?php
$ret = Phalcon\Date::valid('2012-01-22 11:00:00', 'Y-m-d H:i:s');
根据需要的单位返回日期:
<?php
$span = Phalcon\Date::span(60, 182, 'minutes,seconds'); // array('minutes' => 2, 'seconds' => 2)
$span = Phalcon\Date::span(60, 182, array('minutes', 'seconds')); // array('minutes' => 2, 'seconds' => 2)
$span = Phalcon\Date::fuzzy_span(time() - 120, time()); // "a few minutes"
$span = Phalcon\Date::fuzzy_span2(60); // "1 minutes"
$time = Phalcon\Date::formatted_time('5 minutes ago');
显示更容易理解的时间值:
<?php
$span = Phalcon\Date::fuzzy_span(time() - 10); // "moments ago"
$span = Phalcon\Date::fuzzy_span(time() - 120, time()); // "a few minutes"
$span = Phalcon\Date::fuzzy_span2(60); // "1 minutes"