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.Fstands for the full month name,jstands for the day of the month without leading zeros, andYstands 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 disable PHP warnings in WordPress?
- How to add a PHP header in WordPress?
- How to use the WordPress REST API with PHP?
- 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 use hooks in WordPress with an example?
- How to hide PHP warnings in WordPress?
- How to create pagination in WordPress using PHP?
- How to make an AJAX request in WordPress using PHP?
See more codes...