jeudi 21 mars 2019

Create the same time diff from a given datetime

I find the different of this two time with the following:

$expiry = new Carbon('Mar 21, 2019 17:40:00');
$create = new Carbon('2019-03-12 07:00:00');
$expiry->diffInSeconds($create);

and I want to create the new expiry with the same time range from today. The expiry need to be in exact same format.

$new_expiry = new Carbon(date("Y-m-d H:i:s", time()));
$new_expiry->addSeconds($sec)->format('M d,Y H:i:s');

I'm getting wrong new_expiry, any better code to do this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire