php-wordpressHow to format a date in WordPress using PHP?
The WordPress function date_i18n()
can be used to format a date in WordPress using PHP. This function takes a timestamp as the first argument and a date format as the second argument.
echo date_i18n( 'F j, Y', time() );
The output of the above code will be something like July 15, 2020
.
Code explanation
date_i18n()
: This is the WordPress function used to format a date.F j, Y
: This is the date format used in the example.F
stands for the full month name,j
stands for the day of the month without leading zeros, andY
stands for the 4-digit year.time()
: This is the timestamp used in the example. It is the current timestamp.
Helpful links
More of Php Wordpress
- How to get the current URL in WordPress using PHP?
- How to disable PHP warnings in WordPress?
- How to increase the upload limit in WordPress using PHP?
- How to check the PHP version in WordPress?
- How to run an SQL query in WordPress using PHP?
- How to create a snippet in WordPress using PHP?
- How to configure Nginx for WordPress?
- How to create a menu in WordPress using PHP?
- How to use get_header in WordPress using PHP?
- How to send an email using PHP in WordPress?
See more codes...