I'm generating a UTC/GMT date with PHP that needs to be in the format yyyyMMddHHmm and needs to be rounded to the nearest minute.
For example, January 3rd, 2020 13:28:56 needs to be 202001031329 and it needs to be rounded to the nearest minute. (30 seconds or greater rounds up, otherwise round down)
For example:
<?php
/*
Start with the UTC/GMT time -- January 3rd, 2020 13:28:56
Round to the nearest minute -- January 3rd, 2020 13:29:00
Convert to format yyyyMMddHHmm -- 202001031329
*/
$date = gmdate("YmdHi", time());
// Need to round to the nearest minute (30 seconds or greater rounds up, otherwise round down)
echo $date;
?>
So far I've figured out how to get the current date with the gmdate() and put it in the right format. However, I'm not sure how to round to the nearest minute.