WPOWCPDF_InvoicesCompatibilityWC_DateTime

WC Wrapper for PHP DateTime.

Defined (1)

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

/includes/compatibility/class-wc-date-compatibility.php  
  1. class WC_DateTime extends \DateTime { 
  2.  
  3. /** 
  4. * Output an ISO 8601 date string in local timezone. 
  5. * @since 3.0.0 
  6. * @return string 
  7. */ 
  8. public function __toString() { 
  9. return $this->format( DATE_ATOM ); 
  10.  
  11. /** 
  12. * Missing in PHP 5.2. 
  13. * @since 3.0.0 
  14. * @return int 
  15. */ 
  16. public function getTimestamp() { 
  17. return method_exists( 'DateTime', 'getTimestamp' ) ? parent::getTimestamp() : $this->format( 'U' ); 
  18.  
  19. /** 
  20. * Get the timestamp with the WordPress timezone offset added or subtracted. 
  21. * @since 3.0.0 
  22. * @return int 
  23. */ 
  24. public function getOffsetTimestamp() { 
  25. return $this->getTimestamp() + $this->getOffset(); 
  26.  
  27. /** 
  28. * Format a date based on the offset timestamp. 
  29. * @since 3.0.0 
  30. * @param string $format 
  31. * @return string 
  32. */ 
  33. public function date( $format ) { 
  34. return gmdate( $format, $this->getOffsetTimestamp() ); 
  35.  
  36. /** 
  37. * Return a localised date based on offset timestamp. Wrapper for date_i18n function. 
  38. * @since 3.0.0 
  39. * @param string $format 
  40. * @return string 
  41. */ 
  42. public function date_i18n( $format = 'Y-m-d' ) { 
  43. return date_i18n( $format, $this->getOffsetTimestamp() );