1

I'm looking for the following solution in PHP.

Whenever a user clicks on a page I want to store the time they clicked as an half hour interval in 12 hour AM/PM format.

For example a user clicks at: 7:23AM will be stored as 7:00AM-7:30AM, 9:44PM will be stored as 9:30PM-10:00PM, etc

1 Answers1

1
var_dump( date('H:i') );
$prev = time() - (time() % 1800);
$next = $prev + 1800;
var_dump( date('H:i A', $prev), date('H:i A', $next) );

as seen here: How to round unix timestamp up and down to nearest half hour?

Community
  • 1
  • 1
gherkins
  • 14,603
  • 6
  • 44
  • 70