Replace the existing SQL query in sqldates.php with this similar one:

INSERT INTO task (tasktime, task) VALUES (DATE_ADD(NOW(), INTERVAL 7 DAY), 'Call John');

Load the page in a browser and it should be blank.  Change the last bit of the query to read INTERVAL 1 DAY), 'Barbers');.  Save and try the page again.

Go to PHPMyadmin and Browse the tasks table.  You should see two scheduled tasks with different dates and times.

NOW() is the current date and time.  In the above query you added an interval of 7 days to that using DATE_ADD.  You could have added months or years in the same way.  DATE_SUB allows you to subtract days, months or years from a date.


ADDTIME and SUBTIME work a bit differently and only on times (and days but best to ignore that).  In sqldates.php copy the whole query line and paste it under itself so you now have two identical queries.  You might want to add comments later explaining what each line does.  Change the query in the second one to this:​

INSERT INTO task (tasktime, task) VALUES (ADDTIME(NOW(), '00:00:10.0'), 'Drink tea');

​Save and try.  In PHPMyAdmin Browse you should see two new tasks one scheduled very soon.  The last digit is for tenths of a second and you can also do hundredths and milliseconds.

Date format

Note the sensible date format which allows easy sorting by year, then month, then date etc..