Categories: wordpress

DATE AND TIME IN WORDPRESS DEVELOPMENT

This article gives idea about two types of date.
THE FIRST
a) date
if you want to show todays date you can use this format

echo “Today is ” . date(“Y/m/d”)

The symbol here
Y: full year (2020)
y: short form of year (20)
m: numerical form of month (7)
M: Alphabetical form of Month (July)
d: date (16)
D: short form of day (Thu)
l: Full form of Day (Thursday)

b) Time
samewse in date() you can echo time like date(h:i:s a)
this gives the hour, minute and second along with am and pm
H: 24 hour format
h: 12 hour format
i: minute (00 to 59)
s: second (00 to 59)
a: shows am or pm

THE SECOND
date of the post

  1. the_date()
    This will give the Date in the F j, Y format ie. JULY 16, 2020
    you can also do echo get_the_date(); for this
  • DATE FORMAT
  • the_date() gives JULY 16, 2020 by default
  • echo get_the_date( l, S M Y ) gives Thursday, 16th July 2020.
  • the_time( ‘g:i a’ ) gives output of 7:30 am
  • echo get_the_time( ‘G:i’ ) give 24 hur format that is 23:20
  • the_time( ‘g:i a, D, j F y’ )gives 2:03 pm, Thu, 16 July 20
jaminrai

Recent Posts

Skype Closes Its Doors After 20 Years: A Look Back and the Apps That Faded with It

After 20 years of transforming global communication, Skype has officially ceased operations. Microsoft, which purchased…

2 months ago

The Duck and the Tortoise: A Tale of Patience and Teamwork

In a serene forest by the edge of a sparkling lake, there lived a cheerful…

3 months ago

10 Smart Strategies for a Secure and Enjoyable Retirement

Retiring comfortably is a goal many aspire to achieve, and with the right strategies, it’s…

3 months ago

Troubleshooting a Slow Computer

Is your computer running frustratingly slow? Don't worry; you're not alone in facing this common…

3 months ago

The Clever Fox and the Greedy Crow

Once, in a sunny forest, Fox and Crow were friends. One day, Crow found a…

3 months ago