Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/wpforms-.../includes/function...
File: date-time.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Helper functions to work with dates, time and timezones.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 1.8.0
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Return date and time formatted as expected.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 1.6.3
[10] Fix | Delete
*
[11] Fix | Delete
* @param string|int $date Date to format.
[12] Fix | Delete
* @param string $format Optional. Format for the date and time.
[13] Fix | Delete
* @param bool $gmt_offset Optional. GTM offset.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string
[16] Fix | Delete
*/
[17] Fix | Delete
function wpforms_datetime_format( $date, $format = '', $gmt_offset = false ) {
[18] Fix | Delete
[19] Fix | Delete
if ( is_numeric( $date ) ) {
[20] Fix | Delete
$date = (int) $date;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
if ( is_string( $date ) ) {
[24] Fix | Delete
$date = strtotime( $date );
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
if ( $gmt_offset ) {
[28] Fix | Delete
$date += (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
if ( $format === '' ) {
[32] Fix | Delete
return sprintf( /* translators: %1$s - formatted date, %2$s - formatted time. */
[33] Fix | Delete
__( '%1$s at %2$s', 'wpforms-lite' ),
[34] Fix | Delete
date_i18n( get_option( 'date_format' ), $date ),
[35] Fix | Delete
date_i18n( get_option( 'time_format' ), $date )
[36] Fix | Delete
);
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
return date_i18n( $format, $date );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Return date formatted as expected.
[44] Fix | Delete
*
[45] Fix | Delete
* @since 1.6.3
[46] Fix | Delete
*
[47] Fix | Delete
* @param string|int $date Date to format.
[48] Fix | Delete
* @param string $format Optional. Format for the date.
[49] Fix | Delete
* @param bool $gmt_offset Optional. GTM offset.
[50] Fix | Delete
*
[51] Fix | Delete
* @return string
[52] Fix | Delete
*/
[53] Fix | Delete
function wpforms_date_format( $date, $format = '', $gmt_offset = false ) {
[54] Fix | Delete
[55] Fix | Delete
if ( $format === '' ) {
[56] Fix | Delete
$format = (string) get_option( 'date_format', 'M j, Y' );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
return wpforms_datetime_format( $date, $format, $gmt_offset );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Return time formatted as expected.
[64] Fix | Delete
*
[65] Fix | Delete
* @since 1.8.5
[66] Fix | Delete
*
[67] Fix | Delete
* @param string|int $date Date to format.
[68] Fix | Delete
* @param string $format Optional. Format for the time.
[69] Fix | Delete
* @param bool $gmt_offset Optional. GTM offset.
[70] Fix | Delete
*
[71] Fix | Delete
* @return string
[72] Fix | Delete
*/
[73] Fix | Delete
function wpforms_time_format( $date, $format = '', $gmt_offset = false ) {
[74] Fix | Delete
[75] Fix | Delete
if ( $format === '' ) {
[76] Fix | Delete
$format = (string) get_option( 'time_format', 'g:ia' );
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
return wpforms_datetime_format( $date, $format, $gmt_offset );
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Get the certain date of a specified day in a specified format.
[84] Fix | Delete
*
[85] Fix | Delete
* @since 1.4.4
[86] Fix | Delete
* @since 1.6.3 Added $use_gmt_offset parameter.
[87] Fix | Delete
*
[88] Fix | Delete
* @param string $period Supported values: start, end.
[89] Fix | Delete
* @param string $timestamp Default is the current timestamp, if left empty.
[90] Fix | Delete
* @param string $format Default is a MySQL format.
[91] Fix | Delete
* @param bool $use_gmt_offset Use GTM offset.
[92] Fix | Delete
*
[93] Fix | Delete
* @return string
[94] Fix | Delete
*/
[95] Fix | Delete
function wpforms_get_day_period_date( $period, $timestamp = '', $format = 'Y-m-d H:i:s', $use_gmt_offset = false ) {
[96] Fix | Delete
[97] Fix | Delete
$date = '';
[98] Fix | Delete
[99] Fix | Delete
if ( empty( $timestamp ) ) {
[100] Fix | Delete
$timestamp = time();
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
$offset_sec = $use_gmt_offset ? get_option( 'gmt_offset' ) * 3600 : 0;
[104] Fix | Delete
[105] Fix | Delete
switch ( $period ) {
[106] Fix | Delete
case 'start_of_day':
[107] Fix | Delete
$date = gmdate( $format, strtotime( 'today', $timestamp ) - $offset_sec );
[108] Fix | Delete
break;
[109] Fix | Delete
[110] Fix | Delete
case 'end_of_day':
[111] Fix | Delete
$date = gmdate( $format, strtotime( 'tomorrow', $timestamp ) - 1 - $offset_sec );
[112] Fix | Delete
break;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
return $date;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function