Im a seasoned dev that just wants to know if PHP is capable of setting variables at certain times of the day. For instance, I have a video of the day widget which I can manage on my own by changing the WHERE id='$x
', but I'd like $x to $x to be randomized like executing ORDER BY rand() LIMIT 1.
The issue with ORDER BY rand() LIMIT
is that it changes every page load when I'd just want the '$x' from WHERE id='$x'
to be changed at midnight every day.
So does PHP allow time-based executions, or is that considered a cron job? Please note I have no idea im just guessing terms.
PHP is server side script executed by client. If you want it to do specific actions outside normal browsing, you need to set ap a cron job.
If you're computing a "video of the day" link in response to a client request, I'd say go for a rand()
call to determine $x
, but seed the number generator with a value that depends only on the day:
<?php
srand(date('Ymd'));
$videoId = rand(0, 100);// change to whatever your maximum video id is
No need for an extra cron job and you don't need to store the value or modify the script.
hi dear you can use php sever feature 'CRON JOB' this feature throw you can set according time execution of PHP script and update your web or application.
So First of all crate php script and set on SERVER file link and setting as time.
you can read this link and set file link on server.