Forums

time zone

i am writing an app in which the users data (including the time and the user time zone) is stored in a table. now i need to delete the users data at midnight. my plan was to used the PAW schedule tab to schedule a script that read the user data and delete them at midnight but i'm faced with the fact that the users maybe from different time zone. i'm new to dealing with time zones so i'm trying to come up with a solution and this is what i'm planing to do and i would like some input.

first i'm planning to research all the time zone and their UTC equivalent of midnight. then i would run a script that reads the users data and deletes it if the current time of the user time zone is midnight. here is an example of pseudo_code:

for row in user_database: time_zone=row[1]: if current_time_in_this_time_zone==midnight: delete row

i will have to figure out when midnight is at all the time zones so i can schedule the script accordingly. is there a better way of doing this. Thanks.

hmm can't think of anything if you need to delete at different times for different users. (or maybe just delete the next time the user accesses the data? or in your frontend, just show any data that's from user timezone's last midnight?) so then you can just have a single cronjob to delete after 2 days.