Date("F d Y H:i:s") gives current time in php. How can I get delay of 30 secs and 1 min in current time using php, not sure but something like Date ("F d Y H:i:s-30") or Date("F d Y H:i-1:s") ?
date("F d Y H:i:s", time() + 90)
date
has a second, optional parameter: the timestamp to convert to a string. time
returns the current timestamp, which is just an integer, so you can add 90 to it to get the time 90 seconds from the current time.
You mean format the time for 1:30 in the future?
date('format string', time()+90);
In the above, 90 can be any positive or negative offset.
In PHP, dates and times are generally worked with as timestamps ; which are a number of seconds since 1970 or so.
To get the current timestamp, you can use time()
And to format it, you use date()
, as you already know.
So, for current time plus 1 min and 30 seconds (ie, 90 seconds) :
date('F d Y H:i:s', time() + 90);
Or, as an alternate way (a bit more fun ? ), you can use strtotime()
:
echo date('F d Y H:i:s', strtotime('+1 minute +30 seconds'));
OK, more complex in this case, I admit ^^
But, in some other situations, it's good to know it exists ;-)