PluginProbe ʕ •ᴥ•ʔ
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More / 1.9.8.7
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More v1.9.8.7
1.10.1.1 1.10.1 1.10.0.5 trunk 1.1.4 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.6.1 1.1.7 1.1.7.1 1.1.7.2 1.1.8 1.1.8.1 1.1.8.2 1.1.8.3 1.1.8.4 1.10.0.1 1.10.0.2 1.10.0.3 1.10.0.4 1.2.0 1.2.0.1 1.2.1 1.2.2 1.2.2.1 1.2.2.2 1.2.3 1.2.3.1 1.2.3.2 1.2.4 1.2.4.1 1.2.5 1.2.5.1 1.2.6 1.2.7 1.2.8 1.2.8.1 1.2.9 1.3.0 1.3.1 1.3.1.1 1.3.1.2 1.3.2 1.3.3 1.3.5 1.3.6 1.3.6.1 1.3.6.2 1.3.7.2 1.3.7.3 1.3.7.4 1.3.8 1.3.9.1 1.4.0.1 1.4.1.1 1.4.2 1.4.2.1 1.4.2.2 1.4.3 1.4.4 1.4.4.1 1.4.5 1.4.5.1 1.4.5.2 1.4.5.3 1.4.6 1.4.7.1 1.4.7.2 1.4.8.1 1.4.9 1.5.0.1 1.5.0.3 1.5.0.4 1.5.1 1.5.1.1 1.5.1.3 1.5.2.1 1.5.2.2 1.5.2.3 1.5.3 1.5.3.1 1.5.4.1 1.5.4.2 1.5.5 1.5.5.1 1.5.6 1.5.6.2 1.5.7 1.5.8.2 1.5.9.1 1.5.9.4 1.5.9.5 1.6.0.1 1.6.0.2 1.6.1 1.6.2.2 1.6.2.3 1.6.3.1 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.7 1.6.7.1 1.6.7.2 1.6.7.3 1.6.8 1.6.8.1 1.6.9 1.7.0 1.7.1.1 1.7.1.2 1.7.2 1.7.2.1 1.7.3 1.7.4 1.7.4.1 1.7.4.2 1.7.5.1 1.7.5.2 1.7.5.3 1.7.5.5 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.7.9.1 1.8.0.1 1.8.0.2 1.8.1.1 1.8.1.2 1.8.1.3 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.3.1 1.8.4 1.8.4.1 1.8.5.2 1.8.5.3 1.8.5.4 1.8.6.2 1.8.6.3 1.8.6.4 1.8.7.2 1.8.8.2 1.8.8.3 1.8.9.1 1.8.9.2 1.8.9.4 1.8.9.5 1.8.9.6 1.9.0.1 1.9.0.2 1.9.0.3 1.9.0.4 1.9.1.1 1.9.1.2 1.9.1.3 1.9.1.4 1.9.1.5 1.9.1.6 1.9.2.1 1.9.2.2 1.9.2.3 1.9.3.1 1.9.3.2 1.9.4.1 1.9.4.2 1.9.5 1.9.5.1 1.9.5.2 1.9.6 1.9.6.1 1.9.6.2 1.9.7.1 1.9.7.2 1.9.7.3 1.9.8.1 1.9.8.2 1.9.8.4 1.9.8.7 1.9.9.2 1.9.9.3 1.9.9.4
wpforms-lite / includes / functions / date-time.php
wpforms-lite / includes / functions Last commit date
access.php 8 months ago builder.php 11 months ago checks.php 6 months ago colors.php 2 years ago data-presets.php 6 months ago date-time.php 11 months ago debug.php 9 months ago education.php 11 months ago escape-sanitize.php 6 months ago filesystem-media.php 1 year ago form-fields.php 8 months ago forms.php 10 months ago list.php 1 year ago payments.php 10 months ago plugins.php 11 months ago privacy.php 1 year ago providers.php 11 months ago utilities.php 5 months ago
date-time.php
119 lines
1 <?php
2 /**
3 * Helper functions to work with dates, time and timezones.
4 *
5 * @since 1.8.0
6 */
7
8 /**
9 * Return date and time formatted as expected.
10 *
11 * @since 1.6.3
12 *
13 * @param string|int $date Date to format.
14 * @param string $format Optional. Format for the date and time.
15 * @param bool $gmt_offset Optional. GTM offset.
16 *
17 * @return string
18 */
19 function wpforms_datetime_format( $date, $format = '', $gmt_offset = false ) {
20
21 if ( is_numeric( $date ) ) {
22 $date = (int) $date;
23 }
24
25 if ( is_string( $date ) ) {
26 $date = strtotime( $date );
27 }
28
29 if ( $gmt_offset ) {
30 $date += (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
31 }
32
33 if ( $format === '' ) {
34 return sprintf( /* translators: %1$s - formatted date, %2$s - formatted time. */
35 __( '%1$s at %2$s', 'wpforms-lite' ),
36 date_i18n( get_option( 'date_format' ), $date ),
37 date_i18n( get_option( 'time_format' ), $date )
38 );
39 }
40
41 return date_i18n( $format, $date );
42 }
43
44 /**
45 * Return date formatted as expected.
46 *
47 * @since 1.6.3
48 *
49 * @param string|int $date Date to format.
50 * @param string $format Optional. Format for the date.
51 * @param bool $gmt_offset Optional. GTM offset.
52 *
53 * @return string
54 */
55 function wpforms_date_format( $date, $format = '', $gmt_offset = false ) {
56
57 if ( $format === '' ) {
58 $format = (string) get_option( 'date_format', 'M j, Y' );
59 }
60
61 return wpforms_datetime_format( $date, $format, $gmt_offset );
62 }
63
64 /**
65 * Return time formatted as expected.
66 *
67 * @since 1.8.5
68 *
69 * @param string|int $date Date to format.
70 * @param string $format Optional. Format for the time.
71 * @param bool $gmt_offset Optional. GTM offset.
72 *
73 * @return string
74 */
75 function wpforms_time_format( $date, $format = '', $gmt_offset = false ) {
76
77 if ( $format === '' ) {
78 $format = (string) get_option( 'time_format', 'g:ia' );
79 }
80
81 return wpforms_datetime_format( $date, $format, $gmt_offset );
82 }
83
84 /**
85 * Get the certain date of a specified day in a specified format.
86 *
87 * @since 1.4.4
88 * @since 1.6.3 Added $use_gmt_offset parameter.
89 *
90 * @param string $period Supported values: start, end.
91 * @param string $timestamp Default is the current timestamp, if left empty.
92 * @param string $format Default is a MySQL format.
93 * @param bool $use_gmt_offset Use GTM offset.
94 *
95 * @return string
96 */
97 function wpforms_get_day_period_date( $period, $timestamp = '', $format = 'Y-m-d H:i:s', $use_gmt_offset = false ) {
98
99 $date = '';
100
101 if ( empty( $timestamp ) ) {
102 $timestamp = time();
103 }
104
105 $offset_sec = $use_gmt_offset ? get_option( 'gmt_offset' ) * 3600 : 0;
106
107 switch ( $period ) {
108 case 'start_of_day':
109 $date = gmdate( $format, strtotime( 'today', $timestamp ) - $offset_sec );
110 break;
111
112 case 'end_of_day':
113 $date = gmdate( $format, strtotime( 'tomorrow', $timestamp ) - 1 - $offset_sec );
114 break;
115 }
116
117 return $date;
118 }
119