Last active
September 16, 2019 13:33
-
-
Save eto4detak/5b48fa2e6d623383a5144fdf075a682f to your computer and use it in GitHub Desktop.
php date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = '15:17 14.09.2019'; | |
$d = strtotime($str); | |
echo date_diff(new DateTime(), new DateTime('15:17 15.09.2019'))->days; | |
// format | |
$str = '2019-07-27T10:44:15+10:00'; | |
$d = date("jS F, Y", strtotime($str)); | |
/////////////////////////////////////////////////////////////////////////////////////////// | |
/////// check data | |
/////////////////////////////////////////////////////////////////////////////////////////// | |
public static function valid_period_to_order($cart_item_data, $id_auto) | |
{ | |
foreach (self::get_order_time($id_auto) as $key => $period) { | |
$t1_equally = strtotime($period['start-time']) == strtotime($cart_item_data['pixba_booking']['Finish time']); | |
$t2_equally = strtotime($period['finish-time']) == strtotime($cart_item_data['pixba_booking']['Start time']); | |
$t1 = strtotime($period['start-time']) < strtotime($cart_item_data['pixba_booking']['Start time']); | |
$t2 = strtotime($period['start-time']) < strtotime($cart_item_data['pixba_booking']['Finish time']); | |
$t3 = strtotime($period['finish-time']) < strtotime($cart_item_data['pixba_booking']['Start time']); | |
$t4 = strtotime($period['finish-time']) < strtotime($cart_item_data['pixba_booking']['Finish time']); | |
// есть смежные даты бронирования | |
if($t1_equally || $t2_equally){ | |
}else{ | |
// есть в брони | |
if( ( ($t1 ^ $t2) || ($t3 ^ $t4) ) ){ | |
self::$settings['notice'][] = self::$strings['date_is_booked']; | |
} | |
} | |
} | |
} | |
$start_date = DateTime::createFromFormat('Y-m-d', $start_date_text); | |
$start_date->modify('+1 day'); | |
$finish_time = DateTime::createFromFormat(self::$settings['date_format'], $cart_item_data['pixba_booking']['Finish time']); | |
$str_date = date('Y-m-d', time()); | |
$today = DateTime::createFromFormat('Y-m-d', date('Y-m-d', time()) ); | |
/*======================================================== | |
* russian_date | |
========================================================*/ | |
function russian_date(){ | |
$date=explode(".", date("d.m.Y")); | |
switch ($date[1]){ | |
case 1: $m='января'; break; | |
case 2: $m='февраля'; break; | |
case 3: $m='марта'; break; | |
case 4: $m='апреля'; break; | |
case 5: $m='мая'; break; | |
case 6: $m='июня'; break; | |
case 7: $m='июля'; break; | |
case 8: $m='августа'; break; | |
case 9: $m='сентября'; break; | |
case 10: $m='октября'; break; | |
case 11: $m='ноября'; break; | |
case 12: $m='декабря'; break; | |
} | |
echo $m; | |
} | |
russian_date(); | |
/*======================================================== | |
* Timezone | |
========================================================*/ | |
private static function getWpTimezone() { | |
if (!empty(self::$timezone)) { | |
return self::$timezone; | |
} | |
$timezone_string = get_option( 'timezone_string' ); | |
if (!empty($timezone_string)) { | |
return self::$timezone = new DateTimeZone($timezone_string); | |
} | |
$offset = get_option( 'gmt_offset' ); | |
$hours = (int) $offset; | |
$minutes = abs( ( $offset - (int) $offset ) * 60 ); | |
$offset = sprintf( '%+03d:%02d', $hours, $minutes ); | |
return self::$timezone = new DateTimeZone($offset); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment