How to Declare a variable which increment variable after one day is passed in PHP

Abdur Rahman asked
javascript php

I need to increament variable on the basis of number of day. For example

just Like $day = “120”; then tomorrow that $day variable is 121.


You can do this if you know what the starting count is, and at what time you began counting. You won’t need a database if you have those two pieces of information up front.

$start_count = 120; // Original starting position (counter).
$start_time  = strtotime('2017-11-08 00:00:00'); // Original start time.
                                                 // Format is YYYY-MM-DD HH:MM:SS

$now  = time(); // Time now, in seconds.
$diff = $now - $start_time; // Difference, in seconds.

$days          = floor($diff / 86400); // Divide by seconds in one day.
$current_count = $start_count + $days; // Start count + days since start time.
Share This
Posted in: