Refer to the above video for complete details on using the following code snippet.
Add this code snippet to the bottom of your functions.php file in the active theme. In the parenthesis of return Date() is where you enter the time format you want displayed. For example “F j, Y, g:i a” will show like December 20, 2021, 8:16 pm and will be based on your sites Settings > General.
Remember to add the open & close brackets [ ] to the shortcode
/* Flex Date Shortcode */
add_shortcode('get_flex_date','get_flex_date');
function get_flex_date(){
return Date("D M j, Y, g:i a");
}
Assuming today is December 20th, 2017, 8:16:18 pm, and that we are in the Central Standard Time (CST) Time Zone, Here are some reference php time codes. Be sure to include the double quotes on either side of the codes.
("F j, Y, g:i a") Shows As >> December 20, 2021, 8:16 pm
("m.d.y") Shows As >> 12.20.21
("j, n, Y") Shows As >> 20, 12, 2021
("Ymd") Shows As >> 20211220
('h-i-s, j-m-y, it is w Day') Shows As >> 08-16-18, 20-12-21, 1631 1618 6 Tuepm17
('\i\t \i\s \t\h\e jS \d\a\y.') Shows As >> it is the 20th day.
("D M j G:i:s T Y") Shows As >> Tue Dec 20 20:16:18 CST 2021
('H:m:s \m \i\s\ \m\o\n\t\h') Shows As >> 20:03:18 m is month
("H:i:s") Shows As >> 20:16:18
Offset Flex Dates
Add this code snippet to the bottom of your functions.php file in the active theme. In the parentesis of return Date() is where you enter the time format you want displayed. For example “F j, Y, g:i a” will show like December 20, 2021, 8:16 pm and will be based on your sites Settings > General.
For offset dates refer to the video for details
/* Offset Flex Dates */
add_shortcode('get_flex_date','get_flex_date');
function get_flex_date(){
return Date("D M j");
}
More PHP Date Codes
List of more PHP date codes:
https://www.php.net/manual/en/function.date.php