How do I generate a random time interval and add it to a mysql datetime using php?

Problem :

I have many rows in mysql table with datetime's in the format of:

2008-12-08 04:16:51 etc

I'd like to generate a random time interval of anywhere between 30 seconds, and 3 days and add them to the time above.

a) how do I generate a random time between 30 and 3 days?

b) how do I add this time to the date time format above?

I imagine i need to do a loop to pull out all the info, do the math in php, and then update the row...

Any ideas?

Solution :

easier way.

$new_date = date('Y-m-d h:i:s', strtotime('2008-12-08 04:16:51 +'.rand(30, 60 * 60 * 24 * 3).' seconds'));

Mysql Tutorials

Mysql Howto..

MYSQL - How to SELECT CASE (two tables, if not present in one, check the other)

How to retrieve number of users from mysql db by using other db as reference?

How to best handle exception to repeating calendar events

How do I connect to mysql server with Go and go-sql-driver?

How to display the tables within MySQL? Keeps showing empty set

What version and how to use free MySQL DBMS in commercial projects? [closed]

how to define null as integer value on mysql server?

If duplicate key, how do I determine which primary key (multi) triggered it

How do I find records when data entry has been inconsistent?

How to convert date in Text box to MySQL DATETIME format

PHP: How I Can save the name of hyperlink in text box

How to insert into a mysql table only if not already existing?

How to prevent mySQL from resetting auto increment value?

How to address multiple columns as one in MySQL?

How to i discrete arraylist elements

How to know relations between tables

how to use quote in mysql syntax?

How to send activation link to email in android app [closed]

How to join two tables mysql?

How to insert integer values with query in MySQL in R?

How to rewrite this php slugify function to mysql?

How to execute different query based on the result got from executing query in mysql?

MySQL: low cardinality/selectivity columns = how to index?

Multiple mysql joins, how to combine these 2 select statments

How to connect to MySQL via Standard TCP/IP over SSH using go-sql-driver?

How to backup my MySQL's databases on Windows Vista?

How to Connect to MySQL in R through SSH from a remote Ubuntu machine

how to do a sum in mysql

how to design this database

How to select particular range of values from joining two tables in mysql?