Skip to content
Advertisement

Convert an int to time()

I want to send a reminder email “x” days after an initial email was send.

The admin can choose after how many days they want to send a reminder (after the date of the initial mail).

This amount is stored in this function and returns an integer (for example 14)

JavaScript

The date/time of that the initial email was send is stored in this function

JavaScript

Now I want to write an if statement so that the reminder will be send out “x” days after the date of the initial mail was send.

I guess it will look something like this:

JavaScript

This won’t work because I have to covert the output of setwasNotified() and getAmountDayReminder() so that I can add them.

Is this a good solution and how would I execute this exactly?

Advertisement

Answer

I would use the DateTime modify to add getAmountDayReminder() to the time where the first notification has been sent and then compare this to the current time.

Something like that:

JavaScript

Do not forget to store whether you already sent the reminder. And doing such things in a cron job is probably a good idea.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement