Henk Rensenbrink Henk Rensenbrink - 7 months ago 38
MySQL Question

my timestamp not working with strotime

Good morning,

I have tried to search it up, but it seems I can't find the correct answer.
Currently I am uploading the current time from one of my scripts after a first email is being send to companies, so after it has been send it will upload

to one of my tables in MySQL. This is uploading

Another script will resend a different email after five days with the partial script

if( $company_timestamp < strtotime('-5 days') && $email_sent == "NO" ){

is the date and time told before.
It is indeed sending the email, but it seems it is not getting the correct time, because it is sending this email even after 5 seconds.
Is the format wrong of the date and time? And how can I make
work with my
in the database.


You should define how strototime() should act. In your case you would have to define it this way: date('Y-m-d H:i:s', strtotime('-5 days')); as your variable $company_timestamp returns YYYY-MM-DD HH:ii:ss. Another option would be to transform your variable to "strtotime" date. So: strtotime($company_timestamp).

So your code would be in the first case:

if( $company_timestamp < date('Y-m-d H:i:s', strtotime('-5 days')) && $email_sent == "NO" ){