jp_sitemap_datetime

Convert '0000-00-00 00:00:00' to '0000-00-00T00:00:00Z'.

Description

(string) jp_sitemap_datetime( (string) $datetime ); 

Note that the input is assumed to be in UTC (a.k.a. GMT).

Returns (string)

The converted timestamp.

Parameters (1)

0. $datetime (string)
The timestamp to convert.

Usage

  1. if ( !function_exists( 'jp_sitemap_datetime' ) ) { 
  2. require_once '/modules/sitemaps/sitemap-constants.php'; 
  3.  
  4. // The timestamp to convert. 
  5. $datetime = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jp_sitemap_datetime($datetime); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/sitemaps/sitemap-constants.php  
  1. function jp_sitemap_datetime( $datetime ) { 
  2. $regex = '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/'; 
  3.  
  4. if ( preg_match( $regex, $datetime ) ) { 
  5. return str_replace( ' ', 'T', $datetime ) . 'Z'; 
  6. } else { 
  7. return $datetime;