对于我的Web应用程序,我正在使用PHP类来对齐以各种格式(如图章和日期)使用的日期和时间。 我的应用程序是一个网络爬虫,也是一个自定义的Twitter应用程序。 两者都需要每日报告,因此使精确的时间保持至关重要。 当我使用Unix时间戳格式在整个应用程序中进行数据库存储时,就更是如此。 这使我的计算变得容易得多。 系统设计是通过为时间00:00:00设置Unix时间戳来为单个日期创建时间戳。 我将其称为“ todayStamp00”。

我的问题是我无法让我的班级产生我期望的结果。 它似乎在time(),date()等函数之间有所不同,并且在大多数情况下对我而言是随机的。 我会纠正它偏离的地方,但对这种解决方案不满意。

PS。 我创建了一个组件,该组件可用于替换控制器类中的现有代码段。

<?php
define(DEBUG,1);

class DateTimeComponent {

    private $date;
    private $hour;
    private $day;
    private $timezone;
    private $timeStamp;
    private $nowDateTime;
    private $todayDate;
    private $todayDate00;
    private $todayStamp00;

    public function __construct() {
        # set date object 
        $this->__setDateTime();
    }

    private function __setDateTime() {
        # Date setting object style
            $date = new DateTime('', new DateTimeZone('Europe/Amsterdam'));
        # set datetime for now 
            $this->nowDateTime = $date->format('Y-m-d H:i:s');
            if(DEBUG) echo "this->nowDateTime: ".$this->nowDateTime.PHP_EOL;        
        # add timezone offset +1 for local time Amsterdam
            date_add($date, date_interval_create_from_date_string('1 hours'));
            $this->timeStamp = $date->getTimestamp();
            if(DEBUG) echo "this->Timestamp now: ".$this->timeStamp. "\n";
        # set date today 00:00:00 hours
            date_time_set($date, 0, 0, 0);
            $this->todayDate00 = $date->format('Y-m-d H:i:s');
            if(DEBUG) echo "this->Today 00:00:00: ".$this->todayDate00.PHP_EOL;
        # set date today 00:00:00 hours
            date_add($date, date_interval_create_from_date_string('1 hours'));
            $this->todayStamp00 = $date->getTimestamp();
            if(DEBUG) echo "this->TodayStamp 00:00:00: ".$this->todayStamp00.PHP_EOL;
        $this->date = $date;
        return;
    }

    public function __timestamp() {
        return $this->timeStamp;
    }

    public function __nowDateTime() {
        return $this->nowDateTime;
    }

    public function __todayStamp00() {
        return $this->todayStamp00;
    }

    public function __todayDate00() {
        return $this->todayDate00;
    }

    public function __dateXDaysFromNow($op='substract',$days='1') {
        # calculate plus/minus days from now. Returns daydate00:00:00
        $date = $this->date;
        $datestring = $days." days";
        if($op == "add") {
            date_add($date,date_interval_create_from_date_string($datestring));
        }
        else {
            date_sub($date,date_interval_create_from_date_string($datestring));
        }
        date_time_set($date, 0, 0, 0);
        $day = $date->format('Y-m-d H:i:s');
        return $day;
    }
}
?>

#1楼 票数:0

我已经将其设置为对我有用的东西,因为目前我仅使用1个时区,这是+01:00小时,并且适用于此更新的类。 它需要更多代码行才能使其适用于分钟数不为00的区域(+00:30将不起作用,01:00仅增加1小时)以及与脚本时区具有负差的区域。 那可以满足我的需求。 冬季来临时,病假增加了补偿荷兰当地夏令时校正或夏/冬时间的功能。

<?php
define('DEBUG',1);

/*
 *  Class DateTimeComponent
 *  Use __contruct('timezone') with an timezone_name from timezones array
 *  loads the offset, compares script timezone offset with time choosen.
 *  If timezone choosen not is timezone script it sets script to desired.
 *  
 *  TO DO: 
 *  only works with zones in +00..N zones and ignores the minutes. 
 *  Needs convert from +00:00 and -00:00 (gmt_diff) to decimal +/- hours. 
 * 
*/

class DateTimeComponent {

    private $date;
    private $hour=3600;
    private $day=84600;
    private $timezone;
    private $timezones;
    private $timeStamp;
    private $nowDateTime;
    private $todayDate00;
    private $todayStamp00;
    private $gmt_diff;
    private $tz_offset;

    public function __construct($tz='Europe/Berlin') {
        # load GMT time_zones array
        $this->timezones = $this->setTimezones();
        # get/set the desired zone + offset by name
        foreach($this->timezones as $i=>$timezone) {
            if($timezone['timezone_name'] == $tz) {
                $this->timezone = $timezone['timezone_name'];
                $this->gmt_diff = $timezone['gmt_diff'];
                $operator = substr($this->gmt_diff,0,1);
                if(substr($this->gmt_diff,1,1) == '0') {
                    $this->tz_offset = $operator."".substr($this->gmt_diff,2,1);
                }
                else {
                    $this->tz_offset = substr($this->gmt_diff,1,2);
                }
            }
        }
        $this->date = $this->__setDateTime();
        # define('DEBUG',1)
        if(DEBUG) $this->__debug();
    }

    public function __timestamp() {
        return $this->timeStamp;
    }

    public function __nowDateTime() {
        return $this->nowDateTime;
    }

    public function __todayStamp00() {
        return $this->todayStamp00;
    }

    public function __todayDate00() {
        return $this->todayDate00;
    }

    public function __dateXDaysFromNow($op='substract',$days='1') {
        # calculate plus/minus days from now. Returns daydate00:00:00
        $date = $this->date;
        $datestring = $days." days";
        if($op == "add") {
            date_add($date,date_interval_create_from_date_string($datestring));
        }
        else {
            date_sub($date,date_interval_create_from_date_string($datestring));
        }
        date_time_set($date, 0, 0, 0);
        $day = $date->format('Y-m-d H:i:s');
        return $day;
    }

    private function __setDateTime() {      
        # Date setting object style
        $date = new DateTime('', new DateTimeZone($this->timezone));
        $this->nowDateTime = $date->format('Y-m-d H:i:s');             
        # compare real / desired
        $seconds = date_offset_get($date);
        $currentOffset = ($seconds / 3600);
        if($this->tz_offset != $currentOffset)
        {
                $offset = "$currentOffset hours";
        }else { 
                $offset = "$this->tz_offset hours"; 
        }
        #set offset to disered    
        date_add($date, date_interval_create_from_date_string($offset));
        $this->timeStamp = ($date->getTimestamp());
        # set date/stamp today etc
        date_time_set($date, 0, 0, 0);
        $this->todayDate00 = $date->format('Y-m-d H:i:s');
        $this->todayStamp00 = strtotime($date->format('Y-m-d H:i:s'));
        return $date;
    }

    private function __debug(){
        $errMsg  = "<pre>DEBUG INFO DateTimeComponent".PHP_EOL;
        $errMsg .= "date(obj) datetime: ".$this->nowDateTime.PHP_EOL;
        $errMsg .= "date(obj) current datetime".$this->nowDateTime.PHP_EOL;
        $errMsg .= "date(obj) current timestamp: ".$this->timeStamp.PHP_EOL;
        $errMsg .= "date(obj) today 00:00:00 hours: ".$this->todayDate00.PHP_EOL;
        $errMsg .= "date(obj) today 00:00:00 hours: ".$this->todayStamp00.PHP_EOL;
        $errMsg .= "date(obj) yesterday 00:00:00 hours: ".$yesterday00 = $this->__dateXDaysFromNow().PHP_EOL;
        $errMsg .= "yesterday 00:00:00 hours stamp: ".  strtotime($yesterday00) .PHP_EOL;
        echo $errMsg."</pre>".PHP_EOL;
        return;
    }

    private function setTimezones() {
            $timezones = array(
            array('id' => '1','timezone_name' => 'Pacific/Midway','timezone_label' => '(GMT-11:00) Midway Island, Samoa','gmt_diff' => '-11:00'),
            array('id' => '2','timezone_name' => 'America/Adak','timezone_label' => '(GMT-10:00) Hawaii-Aleutian','gmt_diff' => '-10:00'),
            array('id' => '3','timezone_name' => 'Etc/GMT+10','timezone_label' => '(GMT-10:00) Hawaii','gmt_diff' => '-10:00'),
            array('id' => '4','timezone_name' => 'Pacific/Marquesas','timezone_label' => '(GMT-09:30) Marquesas Islands','gmt_diff' => '-09:30'),
            array('id' => '5','timezone_name' => 'Pacific/Gambier','timezone_label' => '(GMT-09:00) Gambier Islands','gmt_diff' => '-09:00'),
            array('id' => '6','timezone_name' => 'America/Anchorage','timezone_label' => '(GMT-09:00) Alaska','gmt_diff' => '-09:00'),
            array('id' => '7','timezone_name' => 'America/Ensenada','timezone_label' => '(GMT-08:00) Tijuana, Baja California','gmt_diff' => '-08:00'),
            array('id' => '8','timezone_name' => 'Etc/GMT+8','timezone_label' => '(GMT-08:00) Pitcairn Islands','gmt_diff' => '-08:00'),
            array('id' => '9','timezone_name' => 'America/Los_Angeles','timezone_label' => '(GMT-08:00) Pacific Time (US & Canada)','gmt_diff' => '-08:00'),
            array('id' => '10','timezone_name' => 'America/Denver','timezone_label' => '(GMT-07:00) Mountain Time (US & Canada)','gmt_diff' => '-07:00'),
            array('id' => '11','timezone_name' => 'America/Chihuahua','timezone_label' => '(GMT-07:00) Chihuahua, La Paz, Mazatlan','gmt_diff' => '-07:00'),
            array('id' => '12','timezone_name' => 'America/Dawson_Creek','timezone_label' => '(GMT-07:00) Arizona','gmt_diff' => '-07:00'),
            array('id' => '13','timezone_name' => 'America/Belize','timezone_label' => '(GMT-06:00) Saskatchewan, Central America','gmt_diff' => '-06:00'),
            array('id' => '14','timezone_name' => 'America/Cancun','timezone_label' => '(GMT-06:00) Guadalajara, Mexico City, Monterrey','gmt_diff' => '-06:00'),
            array('id' => '15','timezone_name' => 'Chile/EasterIsland','timezone_label' => '(GMT-06:00) Easter Island','gmt_diff' => '-06:00'),
            array('id' => '16','timezone_name' => 'America/Chicago','timezone_label' => '(GMT-06:00) Central Time (US & Canada)','gmt_diff' => '-06:00'),
            array('id' => '17','timezone_name' => 'America/New_York','timezone_label' => '(GMT-05:00) Eastern Time (US & Canada)','gmt_diff' => '-05:00'),
            array('id' => '18','timezone_name' => 'America/Havana','timezone_label' => '(GMT-05:00) Cuba','gmt_diff' => '-05:00'),
            array('id' => '19','timezone_name' => 'America/Bogota','timezone_label' => '(GMT-05:00) Bogota, Lima, Quito, Rio Branco','gmt_diff' => '-05:00'),
            array('id' => '20','timezone_name' => 'America/Caracas','timezone_label' => '(GMT-04:30) Caracas','gmt_diff' => '-04:30'),
            array('id' => '21','timezone_name' => 'America/Santiago','timezone_label' => '(GMT-04:00) Santiago','gmt_diff' => '-04:00'),
            array('id' => '22','timezone_name' => 'America/La_Paz','timezone_label' => '(GMT-04:00) La Paz','gmt_diff' => '-04:00'),
            array('id' => '23','timezone_name' => 'Atlantic/Stanley','timezone_label' => '(GMT-04:00) Faukland Islands','gmt_diff' => '-04:00'),
            array('id' => '24','timezone_name' => 'America/Campo_Grande','timezone_label' => '(GMT-04:00) Brazil','gmt_diff' => '-04:00'),
            array('id' => '25','timezone_name' => 'America/Goose_Bay','timezone_label' => '(GMT-04:00) Atlantic Time (Goose Bay)','gmt_diff' => '-04:00'),
            array('id' => '26','timezone_name' => 'America/Glace_Bay','timezone_label' => '(GMT-04:00) Atlantic Time (Canada)','gmt_diff' => '-04:00'),
            array('id' => '27','timezone_name' => 'America/St_Johns','timezone_label' => '(GMT-03:30) Newfoundland','gmt_diff' => '-03:30'),
            array('id' => '28','timezone_name' => 'America/Araguaina','timezone_label' => '(GMT-03:00) UTC-3','gmt_diff' => '-03:00'),
            array('id' => '29','timezone_name' => 'America/Montevideo','timezone_label' => '(GMT-03:00) Montevideo','gmt_diff' => '-03:00'),
            array('id' => '30','timezone_name' => 'America/Miquelon','timezone_label' => '(GMT-03:00) Miquelon, St. Pierre','gmt_diff' => '-03:00'),
            array('id' => '31','timezone_name' => 'America/Godthab','timezone_label' => '(GMT-03:00) Greenland','gmt_diff' => '-03:00'),
            array('id' => '32','timezone_name' => 'America/Argentina/Buenos_Aires','timezone_label' => '(GMT-03:00) Buenos Aires','gmt_diff' => '-03:00'),
            array('id' => '33','timezone_name' => 'America/Sao_Paulo','timezone_label' => '(GMT-03:00) Brasilia','gmt_diff' => '-03:00'),
            array('id' => '34','timezone_name' => 'America/Noronha','timezone_label' => '(GMT-02:00) Mid-Atlantic','gmt_diff' => '-02:00'),
            array('id' => '35','timezone_name' => 'Atlantic/Cape_Verde','timezone_label' => '(GMT-01:00) Cape Verde Is.','gmt_diff' => '-01:00'),
            array('id' => '36','timezone_name' => 'Atlantic/Azores','timezone_label' => '(GMT-01:00) Azores','gmt_diff' => '-01:00'),
            array('id' => '37','timezone_name' => 'Europe/Belfast','timezone_label' => '(GMT) Greenwich Mean Time : Belfast','gmt_diff' => '+00:00'),
            array('id' => '38','timezone_name' => 'Europe/Dublin','timezone_label' => '(GMT) Greenwich Mean Time : Dublin','gmt_diff' => '+00:00'),
            array('id' => '39','timezone_name' => 'Europe/Lisbon','timezone_label' => '(GMT) Greenwich Mean Time : Lisbon','gmt_diff' => '+00:00'),
            array('id' => '40','timezone_name' => 'Europe/London','timezone_label' => '(GMT) Greenwich Mean Time : London','gmt_diff' => '+00:00'),
            array('id' => '41','timezone_name' => 'Africa/Abidjan','timezone_label' => '(GMT) Monrovia, Reykjavik','gmt_diff' => '+00:00'),
            array('id' => '42','timezone_name' => 'Europe/Berlin','timezone_label' => '(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna','gmt_diff' => '+01:00'),
            array('id' => '43','timezone_name' => 'Europe/Belgrade','timezone_label' => '(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague','gmt_diff' => '+01:00'),
            array('id' => '44','timezone_name' => 'Europe/Brussels','timezone_label' => '(GMT+01:00) Brussels, Copenhagen, Madrid, Paris','gmt_diff' => '+01:00'),
            array('id' => '45','timezone_name' => 'Africa/Algiers','timezone_label' => '(GMT+01:00) West Central Africa','gmt_diff' => '+01:00'),
            array('id' => '46','timezone_name' => 'Africa/Windhoek','timezone_label' => '(GMT+01:00) Windhoek','gmt_diff' => '+01:00'),
            array('id' => '47','timezone_name' => 'Asia/Beirut','timezone_label' => '(GMT+02:00) Beirut','gmt_diff' => '+02:00'),
            array('id' => '48','timezone_name' => 'Africa/Cairo','timezone_label' => '(GMT+02:00) Cairo','gmt_diff' => '+02:00'),
            array('id' => '49','timezone_name' => 'Asia/Gaza','timezone_label' => '(GMT+02:00) Gaza','gmt_diff' => '+02:00'),
            array('id' => '50','timezone_name' => 'Africa/Blantyre','timezone_label' => '(GMT+02:00) Harare, Pretoria','gmt_diff' => '+02:00'),
            array('id' => '51','timezone_name' => 'Asia/Jerusalem','timezone_label' => '(GMT+02:00) Jerusalem','gmt_diff' => '+02:00'),
            array('id' => '52','timezone_name' => 'Europe/Minsk','timezone_label' => '(GMT+02:00) Minsk','gmt_diff' => '+02:00'),
            array('id' => '53','timezone_name' => 'Asia/Damascus','timezone_label' => '(GMT+02:00) Syria','gmt_diff' => '+02:00'),
            array('id' => '54','timezone_name' => 'Europe/Moscow','timezone_label' => '(GMT+03:00) Moscow, St. Petersburg, Volgograd','gmt_diff' => '+03:00'),
            array('id' => '55','timezone_name' => 'Africa/Addis_Ababa','timezone_label' => '(GMT+03:00) Nairobi','gmt_diff' => '+03:00'),
            array('id' => '56','timezone_name' => 'Asia/Tehran','timezone_label' => '(GMT+03:30) Tehran','gmt_diff' => '+03:30'),
            array('id' => '57','timezone_name' => 'Asia/Dubai','timezone_label' => '(GMT+04:00) Abu Dhabi, Muscat','gmt_diff' => '+04:00'),
            array('id' => '58','timezone_name' => 'Asia/Yerevan','timezone_label' => '(GMT+04:00) Yerevan','gmt_diff' => '+04:00'),
            array('id' => '59','timezone_name' => 'Asia/Kabul','timezone_label' => '(GMT+04:30) Kabul','gmt_diff' => '+04:30'),
            array('id' => '60','timezone_name' => 'Asia/Yekaterinburg','timezone_label' => '(GMT+05:00) Ekaterinburg','gmt_diff' => '+05:00'),
            array('id' => '61','timezone_name' => 'Asia/Tashkent','timezone_label' => '(GMT+05:00) Tashkent','gmt_diff' => '+05:00'),
            array('id' => '62','timezone_name' => 'Asia/Kolkata','timezone_label' => '(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi','gmt_diff' => '+05:30'),
            array('id' => '63','timezone_name' => 'Asia/Katmandu','timezone_label' => '(GMT+05:45) Kathmandu','gmt_diff' => '+05:45'),
            array('id' => '64','timezone_name' => 'Asia/Dhaka','timezone_label' => '(GMT+06:00) Astana, Dhaka','gmt_diff' => '+06:00'),
            array('id' => '65','timezone_name' => 'Asia/Novosibirsk','timezone_label' => '(GMT+06:00) Novosibirsk','gmt_diff' => '+06:00'),
            array('id' => '66','timezone_name' => 'Asia/Rangoon','timezone_label' => '(GMT+06:30) Yangon (Rangoon)','gmt_diff' => '+06:30'),
            array('id' => '67','timezone_name' => 'Asia/Bangkok','timezone_label' => '(GMT+07:00) Bangkok, Hanoi, Jakarta','gmt_diff' => '+07:00'),
            array('id' => '68','timezone_name' => 'Asia/Krasnoyarsk','timezone_label' => '(GMT+07:00) Krasnoyarsk','gmt_diff' => '+07:00'),
            array('id' => '69','timezone_name' => 'Asia/Hong_Kong','timezone_label' => '(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi','gmt_diff' => '+08:00'),
            array('id' => '70','timezone_name' => 'Asia/Irkutsk','timezone_label' => '(GMT+08:00) Irkutsk, Ulaan Bataar','gmt_diff' => '+08:00'),
            array('id' => '71','timezone_name' => 'Australia/Perth','timezone_label' => '(GMT+08:00) Perth','gmt_diff' => '+08:00'),
            array('id' => '72','timezone_name' => 'Australia/Eucla','timezone_label' => '(GMT+08:45) Eucla','gmt_diff' => '+08:45'),
            array('id' => '73','timezone_name' => 'Asia/Tokyo','timezone_label' => '(GMT+09:00) Osaka, Sapporo, Tokyo','gmt_diff' => '+09:00'),
            array('id' => '74','timezone_name' => 'Asia/Seoul','timezone_label' => '(GMT+09:00) Seoul','gmt_diff' => '+09:00'),
            array('id' => '75','timezone_name' => 'Asia/Yakutsk','timezone_label' => '(GMT+09:00) Yakutsk','gmt_diff' => '+09:00'),
            array('id' => '76','timezone_name' => 'Australia/Adelaide','timezone_label' => '(GMT+09:30) Adelaide','gmt_diff' => '+09:30'),
            array('id' => '77','timezone_name' => 'Australia/Darwin','timezone_label' => '(GMT+09:30) Darwin','gmt_diff' => '+09:30'),
            array('id' => '78','timezone_name' => 'Australia/Brisbane','timezone_label' => '(GMT+10:00) Brisbane','gmt_diff' => '+10:00'),
            array('id' => '79','timezone_name' => 'Australia/Hobart','timezone_label' => '(GMT+10:00) Hobart','gmt_diff' => '+10:00'),
            array('id' => '80','timezone_name' => 'Asia/Vladivostok','timezone_label' => '(GMT+10:00) Vladivostok','gmt_diff' => '+10:00'),
            array('id' => '81','timezone_name' => 'Australia/Lord_Howe','timezone_label' => '(GMT+10:30) Lord Howe Island','gmt_diff' => '+10:30'),
            array('id' => '82','timezone_name' => 'Etc/GMT-11','timezone_label' => '(GMT+11:00) Solomon Is., New Caledonia','gmt_diff' => '+11:00'),
            array('id' => '83','timezone_name' => 'Asia/Magadan','timezone_label' => '(GMT+11:00) Magadan','gmt_diff' => '+11:00'),
            array('id' => '84','timezone_name' => 'Pacific/Norfolk','timezone_label' => '(GMT+11:30) Norfolk Island','gmt_diff' => '+11:30'),
            array('id' => '85','timezone_name' => 'Asia/Anadyr','timezone_label' => '(GMT+12:00) Anadyr, Kamchatka','gmt_diff' => '+12:00'),
            array('id' => '86','timezone_name' => 'Pacific/Auckland','timezone_label' => '(GMT+12:00) Auckland, Wellington','gmt_diff' => '+12:00'),
            array('id' => '87','timezone_name' => 'Etc/GMT-12','timezone_label' => '(GMT+12:00) Fiji, Kamchatka, Marshall Is.','gmt_diff' => '+12:00'),
            array('id' => '88','timezone_name' => 'Pacific/Chatham','timezone_label' => '(GMT+12:45) Chatham Islands','gmt_diff' => '+12:45'),
            array('id' => '89','timezone_name' => 'Pacific/Tongatapu','timezone_label' => '(GMT+13:00) Nuku\'alofa','gmt_diff' => '+13:00'),
            array('id' => '90','timezone_name' => 'Pacific/Kiritimati','timezone_label' => '(GMT+14:00) Kiritimati','gmt_diff' => '+14:00')
          );
          return $timezones;
    }
}

?>

  ask by Daniel Mulder translate from so

未解决问题?本站智能推荐:

1回复

PHP:如何使用日期而不是DateTime在纪元(1970)之前创建日期?

在我的PHP脚本中,我有一个处理生日的函数,如下所示: 问题是,这将返回带有负的$ time数字的false (即,1970年1月1日之前的日期)。 在PHP文档中,有一条评论说确实 请注意,U选项不支持负时间戳(1970年之前)。 您必须使用日期。 我不确定如何使
1回复

MySQL:具有SET time_zone设置的CURDATE()

我会根据用户的设置手动设置时区: 我想从+02:00角度获得今天的价值所在的结果。 但是我也从昨天开始获得价值。 该表中的值例如: 从00:00时区(值存储在数据库中的时区)开始,上述日期为今天。 但是从SET time_zone首选项来看,事实并非如此。 +02:
3回复

从DateTime()获取的日期超过30/31,因此它不会持续数月

我正在使用DateTime()计算2个日期之间的差异,并且它正常工作。 问题是我希望天数格式能够超过整月,所以30/31或更高。 目前的问题在于,当我没有显示月份时,日期只能达到30/31,并且任何超过该日期的任何内容都将被结转以使新的月份重置剩余天数。 我希望能够在这种格式的差异为
7回复

PHP。 日期。 变更格式

例如,如何更改日期, 2012-08-03至使用PHP的时间戳1344024896? 反之吗?
2回复

在PHP中减去日期无效

我在用PHP减去日期时遇到了一个小问题,这是我尝试过的众多代码之一: 这是打印的内容: 如您所见,日期是相同的,无论我使用哪种方法,结果都是相同的。 那我是在某个地方犯了错误还是我想做的事是不可能的吗? 预先感谢您抽出宝贵时间来帮助我并回答我,如果您需要信息,请告诉我。
4回复

计算PHP中的日期间隔[重复]

可能重复: 用PHP减去日期 我有两个Unix时间戳,如何计算它们之间的总天数?
2回复

在PHP中减去日期[重复]

可能重复: 如何使用PHP计算两个日期之间的差异? 我的时间戳以YYYY-MM-DD HH:MM:SS格式存储(例如2010-06-21 20:12:56 )。 检查时间戳有多久的最佳方法是什么? 目前我主要对天数感兴趣。
1回复

如何计算计费周期的日期php的范围?

我想检查时间戳记是否在我的网站中用户的帐单周期范围内。 例如 如果我的用户在2012年3月7日注册。 我想知道他在帐单周期的一个月内是否提出了三个以上的报价。 例如,如果某天(2013年9月4日)他试图提出要约,那么我必须找到他的范围。 我已经将其注册时间的时间戳存储在mysq