• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Baguiowebs

Baguiowebs

Learn WordPress. Build Your Own Site.

  • Contact
  • Build a Site
  • WP Training
  • Library
  • Signup
  • Login
  • Contact
  • Build a Site
  • WP Training
  • Library
  • Signup
  • Login

Flex Date Shortcode

Hi, Login
X

Join Us Forgot Password?

to view this video. Not a member? Join Now!

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

Filed Under: WP Theme Customization

Primary Sidebar

Section 6

WP Theme Customization

Introduction

  • Before We Customize3:49min
  • How To Create A Child Theme4:49min

Shorcodes

  • Personal Greeting Shortcode3:22min
  • Flex Date Shortcode5:45min

Theme Customization Tuts

  • Remove URL Underline4:54min
  • Remove Incorrect Login Shake1:39min
  • Rebrand Admin Bar WP Logo2:46min
  • Remove Top White Space1:33min
  • Adjust Gap Between Posts on Homepage1:55min
  • Add Border Below Header2:19min
  • Customize Site Description2:16min
  • Customize Site Title2:17min
  • Random Admin Announcement4:47min
  • Add Drop-Down Menu To Admin Bar3:59min

Copyright © 2022 Baguiowebs. All Rights Reserved.

  • About
  • Disclaimer
  • Privacy Policy
  • Terms