vendor
7 years ago
admin.php
7 years ago
class-wp-stream-author.php
10 years ago
connector.php
7 years ago
connectors.php
7 years ago
context-query.php
7 years ago
dashboard.php
10 years ago
date-interval.php
10 years ago
db.php
9 years ago
filter-input.php
10 years ago
functions.php
10 years ago
install.php
9 years ago
list-table.php
7 years ago
live-update.php
9 years ago
log.php
10 years ago
network.php
7 years ago
query.php
7 years ago
settings.php
7 years ago
functions.php
31 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Converts a time into an ISO 8601 extended formatted string. |
| 5 | * |
| 6 | * @param int|bool $time Seconds since unix epoc |
| 7 | * @param int $offset Hour offset |
| 8 | * |
| 9 | * @return string an ISO 8601 extended formatted time |
| 10 | */ |
| 11 | function mainwp_wp_stream_get_iso_8601_extended_date( $time = false, $offset = 0 ) { |
| 12 | if ( $time ) { |
| 13 | $microtime = (float) $time . '.0000'; |
| 14 | } else { |
| 15 | $microtime = microtime( true ); |
| 16 | } |
| 17 | |
| 18 | $micro_seconds = sprintf( '%06d', ( $microtime - floor( $microtime ) ) * 1000000 ); |
| 19 | $offset_string = sprintf( 'Etc/GMT%s%s', $offset < 0 ? '+' : '-', abs( $offset ) ); |
| 20 | |
| 21 | $timezone = new DateTimeZone( $offset_string ); |
| 22 | $date = new DateTime( date( 'Y-m-d H:i:s.' . $micro_seconds, $microtime ), $timezone ); |
| 23 | |
| 24 | return sprintf( |
| 25 | '%s%03d%s', |
| 26 | $date->format( 'Y-m-d\TH:i:s.' ), |
| 27 | floor( $date->format( 'u' ) / 1000 ), |
| 28 | $date->format( 'O' ) |
| 29 | ); |
| 30 | } |
| 31 |