PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Helpers / Date.php

Date.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Helpers/Date.php

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Helpers;
4
5 /**
6 * @since 2.20.0
7 */
8 class Date {
9
10 /**
11 * Returns human readable date.
12 *
13 * @param string $datetime A date/time string
14 * @since 2.20.0
15 *
16 * @return string
17 */
18 public static function getDateTime($datetime) {
19 $dateTimestamp = strtotime($datetime);
20 $currentTimestamp = current_time('timestamp');
21 $todayTimestamp = strtotime('today', $currentTimestamp);
22 $yesterdayTimestamp = strtotime('yesterday', $currentTimestamp);
23
24 if ($dateTimestamp >= $todayTimestamp) {
25 return sprintf(
26 '%1$s %2$s %3$s',
27 esc_html__('Today', 'give'),
28 esc_html__('at', 'give'),
29 date_i18n(get_option('time_format'), $dateTimestamp)
30 );
31 }
32
33 if ($dateTimestamp >= $yesterdayTimestamp) {
34 return sprintf(
35 '%1$s %2$s %3$s',
36 esc_html__('Yesterday', 'give'),
37 esc_html__('at', 'give'),
38 date_i18n(get_option('time_format'), $dateTimestamp)
39 );
40 }
41
42 return sprintf(
43 '%1$s %2$s %3$s',
44 date_i18n(get_option('date_format'), $dateTimestamp),
45 esc_html__('at', 'give'),
46 date_i18n(get_option('time_format'), $dateTimestamp)
47 );
48 }
49 }
50