当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Format::ToDate方法代码示例

本文整理汇总了PHP中Gdn_Format::ToDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::ToDate方法的具体用法?PHP Gdn_Format::ToDate怎么用?PHP Gdn_Format::ToDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Format的用法示例。


在下文中一共展示了Gdn_Format::ToDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ConfigureRange

 private function ConfigureRange($Sender)
 {
     // Grab the range resolution from the url or form. Default to "day" range.
     $Sender->Range = GetIncomingValue('Range');
     if (!in_array($Sender->Range, array(VanillaStatsPlugin::RESOLUTION_DAY, VanillaStatsPlugin::RESOLUTION_MONTH))) {
         $Sender->Range = VanillaStatsPlugin::RESOLUTION_DAY;
     }
     // Define default values for start & end dates
     $Sender->DayStampStart = strtotime('1 month ago');
     // Default to 1 month ago
     $Sender->MonthStampStart = strtotime('12 months ago');
     // Default to 24 months ago
     $Sender->DayDateStart = Gdn_Format::ToDate($Sender->DayStampStart);
     $Sender->MonthDateStart = Gdn_Format::ToDate($Sender->MonthStampStart);
     // Validate that any values coming from the url or form are valid
     $Sender->DateRange = GetIncomingValue('DateRange');
     $DateRangeParts = explode('-', $Sender->DateRange);
     $Sender->StampStart = strtotime(GetValue(0, $DateRangeParts));
     $Sender->StampEnd = strtotime(GetValue(1, $DateRangeParts));
     if (!$Sender->StampEnd) {
         $Sender->StampEnd = strtotime('yesterday');
     }
     // If no date was provided, or the provided values were invalid, use defaults
     if (!$Sender->StampStart) {
         $Sender->StampEnd = time();
         if ($Sender->Range == 'day') {
             $Sender->StampStart = $Sender->DayStampStart;
         }
         if ($Sender->Range == 'month') {
             $Sender->StampStart = $Sender->MonthStampStart;
         }
     }
     // Assign the variables used in the page with the validated values.
     $Sender->DateStart = Gdn_Format::ToDate($Sender->StampStart);
     $Sender->DateEnd = Gdn_Format::ToDate($Sender->StampEnd);
     $Sender->DateRange = $Sender->DateStart . ' - ' . $Sender->DateEnd;
     // Define the range boundaries.
     $Database = Gdn::Database();
     // We use the User table as the boundary start b/c users are always inserted before discussions or comments.
     // We have to put a little kludge in here b/c an older version of Vanilla hard-inserted the admin user with an insert date of Sept 16, 1975.
     $Data = $Database->SQL()->Select('DateInserted')->From('User')->Where('DateInserted >', '1975-09-17')->OrderBy('DateInserted', 'asc')->Limit(1)->Get()->FirstRow();
     $Sender->BoundaryStart = Gdn_Format::Date($Data ? $Data->DateInserted : $Sender->DateStart, '%Y-%m-%d');
     $Sender->BoundaryEnd = Gdn_Format::Date($Sender->DateEnd, '%Y-%m-%d');
 }
开发者ID:rnovino,项目名称:Garden,代码行数:44,代码来源:class.vanillastats.plugin.php


注:本文中的Gdn_Format::ToDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。