50 public static function format( $date, $to =
'm/d/Y H:i' )
53 if ( !empty( $date ) ) {
54 $timestamp = strtotime( $date );
55 $result = date( $to, $timestamp );
75 $expiredate = strtotime(
"+{$duration} {$duration_type}", strtotime( $date ) );
90 $diff = $date - time();
91 $days = floatval( round( $diff / ( 60 * 60 * 24 ) ) );
104 return str_replace(
' ',
'<br/>', $datetime );
118 return ( ( $exipration - time() ) <= 0 );
133 public static function isInRangeDatetime( $date_start, $date_expire, $format =
'YmdHis', $timestamp =
false )
135 if ( !empty( $date_start ) || !empty( $date_expire ) ) {
143 $date_start = !empty( $date_start ) ? strtotime( $date_start ) : $now;
144 $date_expire = !empty( $date_expire ) ? strtotime( $$date_expire ) : $now;
147 $date_start = !empty( $date_start ) ? $date_start : $now;
148 $date_expire = !empty( $date_expire ) ? $date_expire : $now;
152 if ( $now >= $date_start && $now <= $date_expire ) {
171 return self::format( $date, self::MYSQL_DATE );
186 return self::format( $datetime, self::MYSQL_DATE_TIME );
198 return substr( $time, 0, 5 );
227 $start_day_number = $week_days[$first_day];
228 $wday = $date->format(
"w" );
229 $current_day_number = ( $wday != 0 ? $wday - 1 : 6 );
247 return ( $date - $days_to_start );
287 if ( !empty( $deprecated ) && func_num_args() > 2 ) {
288 _deprecated_argument( __METHOD__,
'1.0.0.b2' );
291 _deprecated_function( __METHOD__,
'1.0.0',
'format()' );
293 return self::format( $date, $to );
310 _deprecated_function( __METHOD__,
'1.0.0.b2',
'strtotime() PHP function' );
313 $sanitize_date = self::formatFromFormat( $date, $format );
314 $split = explode(
' ', $sanitize_date );
315 $date_part = explode(
'/', $split[0] );
316 $time_part = explode(
':', $split[1] );
317 $time = mktime( $time_part[0], $time_part[1], 0, $date_part[0], $date_part[1], $date_part[2] );
334 if ( !empty( $deprecated ) ) {
335 _deprecated_argument( __METHOD__,
'1.0.0.b2' );
337 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.3.0',
'mySQLDate()' );
338 return self::mySQLDate( $date );
355 if ( !empty( $deprecated ) ) {
356 _deprecated_argument( __METHOD__,
'1.0.0.b2' );
358 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.3.0',
'mySQLDateTime()' );
359 return self::mySQLDateTime( $datetime );