wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.
rest_parse_date › WordPress Function
Od4.4.0
Przestarzałyn/a
› rest_parse_date ( $date, $force_utc = false )
| Parametry: (2) |
|
| Powrót: |
|
| Zdefiniowane na: |
|
| Codex: |
Parses an RFC3339 time into a Unix timestamp.
Explicitly check forfalse to detect failure, as zero is a valid return
value on success.Powiązane Funkcje: rest_parse_hex_color, get_the_date, get_core_updates, list_core_update, rest_parse_embed_param
Źródło
function rest_parse_date( $date, $force_utc = false ) {
if ( $force_utc ) {
$date = preg_replace( '/[+-]\d+:?\d+$/', '+00:00', $date );
}
$regex = '#^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}(?::\d{2})?)?$#';
if ( ! preg_match( $regex, $date, $matches ) ) {
return false;
}
return strtotime( $date );
}