1.2.362. Don’t Add Seconds

Avoid adding seconds to a date, and use DateTime\:\:modify to add an interval.

This method will handle situations like daylight savings, leap seconds and even leap days.

<?php

// Tomorrow, same time
$tomorrow = new DateTime('now')->modify('+1 day');

// Tomorrow, but may be not at the same hour
$tomorrow = date('now') + 86400;

?>

See also DateTime::modify and datetime.

1.2.362.1. Specs

Short name

Structures/DontAddSeconds

Rulesets

All, Analyze

Exakat since

2.3.9

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

date

Available in

Entreprise Edition, Exakat Cloud