本文整理匯總了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');
}