iso8601_to_timestamp
Convert ISO 8601 compliant date string to unix timestamp.
Description
iso8601_to_timestamp( (string) $datestr );
Parameters (1)
- 0. $datestr (string)
- ISO 8601 compliant date string
Usage
if ( !function_exists( 'iso8601_to_timestamp' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce-globalpay/lib/class.nusoap_base.php'; } // ISO 8601 compliant date string $datestr = ''; // NOTICE! Understand what this does before running. $result = iso8601_to_timestamp($datestr);
Defined (2)
The function is defined in the following location(s).
- /lib/class.nusoap_base.php
- function iso8601_to_timestamp($datestr) {
- $pattern = '/'.
- '([0-9]{4})-'. // centuries & years CCYY-
- '([0-9]{2})-'. // months MM-
- '([0-9]{2})'. // days DD
- 'T'. // separator T
- '([0-9]{2}):'. // hours hh:
- '([0-9]{2}):'. // minutes mm:
- '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
- '/';
- if(preg_match($pattern, $datestr, $regs)) {
- // not utc
- if($regs[8] != 'Z') {
- $op = substr($regs[8], 0, 1);
- $h = substr($regs[8], 1, 2);
- $m = substr($regs[8], strlen($regs[8])-2, 2);
- if($op == '-') {
- $regs[4] = $regs[4] + $h;
- $regs[5] = $regs[5] + $m;
- } elseif($op == '+') {
- $regs[4] = $regs[4] - $h;
- $regs[5] = $regs[5] - $m;
- }
- }
- return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
- } else {
- return false;
- }
- }
- /lib/nusoap.php
- function iso8601_to_timestamp($datestr) {
- $pattern = '/'.
- '([0-9]{4})-'. // centuries & years CCYY-
- '([0-9]{2})-'. // months MM-
- '([0-9]{2})'. // days DD
- 'T'. // separator T
- '([0-9]{2}):'. // hours hh:
- '([0-9]{2}):'. // minutes mm:
- '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
- '/';
- if(preg_match($pattern, $datestr, $regs)) {
- // not utc
- if($regs[8] != 'Z') {
- $op = substr($regs[8], 0, 1);
- $h = substr($regs[8], 1, 2);
- $m = substr($regs[8], strlen($regs[8])-2, 2);
- if($op == '-') {
- $regs[4] = $regs[4] + $h;
- $regs[5] = $regs[5] + $m;
- } elseif($op == '+') {
- $regs[4] = $regs[4] - $h;
- $regs[5] = $regs[5] - $m;
- }
- }
- return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
- } else {
- return false;
- }
- }