123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of DateTimeEx
- *
- * @author jgao
- */
- class Date {
- //put your code here
-
- /**
- * 年
- * @var type
- */
- public $year;
- /**
- * 月
- * @var type
- */
- public $month;
- /**
- * 日
- * @var type
- */
- public $day;
- /**
- * 星期
- * @var type
- */
- public $dayofweek;
- /**
- * 时
- * @var type
- */
- public $hours;
- /**
- * 分
- * @var type
- */
- public $minutes;
- /**
- * 秒
- * @var type
- */
- public $seconds;
- /**
- * 时间戳
- * @var type
- */
- public $time;
-
- function __construct($time=0){
- if($time==0){
- $this->time = time();
- }else{
- $this->time = $time;
- }
- $date_reg = date("Y:m:d:H:i:s:N",$this->time);
- $date_info = explode(":",$date_reg);
- $i = 0;
- $this->year = intval($date_info[$i++]);
- $this->month = intval($date_info[$i++]);
- $this->day = intval($date_info[$i++]);
- $this->hours = intval($date_info[$i++]);
- $this->minutes = intval($date_info[$i++]);
- $this->seconds = intval($date_info[$i++]);
- $this->dayofweek = intval($date_info[$i++]);
- }
-
- function toString(){
- return date("Y-m-d H:i:s", $this->time);
- }
-
- }
- ?>
|