0

I'm integrating external API which has expire_in key with value 179999. I need to convert the value to date so that I can compare current date with expired date (expired_in). from the API documentation say it expired in 50 Hour. I know that i can just create manually like strtotime('+50 hour') but still I want to know how can I convert 179999 to date.

what I try

\DateTime::createFromFormat('ymd', 179999)->format('Y-m-d')

but it give me this result 2025-06-07

Hafizu
  • 5
  • 3

2 Answers2

0

Create a new variable,

$new = old() + (6 * 23 * 59 * 60);

6 is the number of days 23 is the number of hours 59 is the number of minutes 60 is the number of seconds

If you want to use CreateFromFormat,

$format = 'Y-m-d';
$date = DateTime::createFromFormat($format, '2009-02-15');
echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
0

To add 179999 seconds to the current date:

$now = new DateTime();
$now->add(new DateInterval('PT179999S')); // adds 179999 secs
echo $now->format('Y-m-d H:i:s');
Raptor
  • 53,206
  • 45
  • 230
  • 366