自定义分钟的时间戳

I would like to make custom timestamps. I need to round the minute of the time to 00 or 30. I made already a PHP code for this:

if (date("i") >= '15' && date("i") < '45') {
    $minute = "30";
}

else {
    $minute = "00";
}

But, now, I want to make the timestamp with the time + date in it.

Does someone have a solution for this? I think I'll need to use strptime but I don't know how exactly..

You can use mktime to generate a timestamp rounded to the nearest 30 minutes:

echo date('Y-m-d H:i:s', mktime(date('H'), round(date('i') / 30) * 30, 0));

Example here:

http://codepad.org/3NCeWO21

The following code snippet:

<?php
date_default_timezone_set('America/New_York');
$format = '%d/%m/%Y %H:%M:%S';
$strf = strftime($format);

print_r(strptime($strf, $format));
?>

Produces this output:

Array
(
    [tm_sec] => 49
    [tm_min] => 48
    [tm_hour] => 8
    [tm_mday] => 14
    [tm_mon] => 3
    [tm_year] => 113
    [tm_wday] => 0
    [tm_yday] => 0
    [unparsed] => 
)

I think you can take it from here.