How to store Birthdate and Age so that Age can be updated daily in PHP/MySQL?

后端 未结 5 1085
天命终不由人
天命终不由人 2020-12-03 06:32

How should I store Birthdate\'s in MySQL so that I can easily update everyone\'s Age on a daily basis via a Cron Job?

Does it even make sense to sto

5条回答
  •  醉话见心
    2020-12-03 06:34

    I don't think it's totally true that computing age dynamically takes a lot of memory. Why not create a table CALENDAR with 365 rows 1 row for each day of an year. And store a list of userid against the day corresponding to their birthday. For each day just refer the table entry for that day and refresh the age of only those selected users. This will reduce the complexity greatly even when the user base increases.

提交回复
热议问题