i need to subtract 30 minutes from current unix timestamp.
I print with this function for print unix timestamp:
echo time(); //ouput: 1412856148
Now I need to print
time() with subtract 30 minutes.
how do print this?
Use the DateTime Object
$time = new DateTime(); $time->modify('-30 minutes'); echo $time->format('U');
The timestamp represent the seconds from the 01.01.1970.
Therefore you can just substract the seconds. You can also format this as a date or something:
date("F j, Y, g:i a", time()-30*60);
time() returns the number of seconds since Jan 1, 1970 seconds so all you have to do is figure out how many seconds are in 30 minutes and then subtract that number from the timestamp.
echo (time() - (30*60));