flexible-shipping
/
vendor_prefixed
/
octolize
/
wp-shipping-extensions
/
src
/
ShippingExtensions
/
DateRange.php
flexible-shipping
/
vendor_prefixed
/
octolize
/
wp-shipping-extensions
/
src
/
ShippingExtensions
Last commit date
Plugin
1 week ago
Promo
1 week ago
Tracker
1 week ago
views
1 week ago
AdminPage.php
1 week ago
Assets.php
1 week ago
DateRange.php
1 week ago
Page.php
1 week ago
PageViewTracker.php
1 week ago
PluginLinks.php
1 week ago
ShippingExtensions.php
1 week ago
TimedUpdate.php
1 week ago
TimedUpdates.php
1 week ago
WooCommerceSuggestions.php
1 week ago
DateRange.php
31 lines
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace FSVendor\Octolize\ShippingExtensions; |
| 5 | |
| 6 | /** |
| 7 | * Date range checked against WordPress current time. |
| 8 | */ |
| 9 | class DateRange |
| 10 | { |
| 11 | /** |
| 12 | * @var string |
| 13 | */ |
| 14 | private $start_date; |
| 15 | /** |
| 16 | * @var string |
| 17 | */ |
| 18 | private $end_date; |
| 19 | public function __construct(string $start_date, string $end_date) |
| 20 | { |
| 21 | $this->start_date = $start_date; |
| 22 | $this->end_date = $end_date; |
| 23 | } |
| 24 | public function is_active(): bool |
| 25 | { |
| 26 | $start_date = strtotime($this->start_date); |
| 27 | $end_date = strtotime($this->end_date); |
| 28 | return current_time('timestamp') < $end_date && current_time('timestamp') > $start_date; |
| 29 | } |
| 30 | } |
| 31 |