1.2.1648. time() Vs strtotime()

time() is actually faster than strtotime() with ‘now’ key string.

This is a micro-optimisation. Relative gain is real, but small unless the function is used many times.

<?php

// Faster version
$a = time();

// Slower version
$b = strtotime('now');

?>

1.2.1648.1. Suggestions

  • Replace strtotime() with time(). Do not change strtotime() with other value than ‘now’.

1.2.1648.2. Specs

Short name

Performances/timeVsstrtotime

Rulesets

All, Changed Behavior, Performances

Exakat since

0.8.7

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Features

declare

Examples

Woocommerce

Available in

Entreprise Edition, Exakat Cloud