当前位置: 首页>>代码示例>>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

 /**
  * Set the date range.
  *
  * @param $Sender
  * @throws Exception
  */
 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(val(0, $DateRangeParts));
     $Sender->StampEnd = strtotime(val(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:caidongyun,项目名称:vanilla,代码行数:50,代码来源:class.vanillastats.plugin.php


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