How to set random datetime in MySQL
Imagine you have to mass insert or update the values in your created_at or updated_at fields. You can easily achieve that with the following SQL query: You can also choose the spread in seconds, 3600 is 1 hour, 86400 is 1 day, 31536000 is 1 year.