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