Home > Back-end >  Unknown date format from API response
Unknown date format from API response

Time:05-02

API Server responds with token expiration date in the following format: 2022-05-09T02:11:27.747 What format is it?

CodePudding user response:

That's ISO-8601 standard time format. Year month day T hour minute second millisecond. The date_parse function will handle this.

<?php

$x = '2021-04-01T19:18:17.654';
print_r(date_parse($x));
?>

Output:

Array
(
    [year] => 2021
    [month] => 4
    [day] => 1
    [hour] => 19
    [minute] => 18
    [second] => 17
    [fraction] => 0.654
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 
)
  • Related