Here is a link to the reason behind this question: NOW() for DATETIME InnoDB Transaction guaranteed?
So to ensure a single transaction with any number of queries (20+ queries for example) has a 100% accurate and consistent NOW() value accross multiple tables, what is the php way to assign a variable equivalent of DATETIME using NOW() (not current TIMESTAMP).
You can do:
<?
$now = time();
$sql = "INSERT INTO table SET field=FROM_UNIXTIME($now)";
$sql2 = "INSERT INTO table SET field=FROM_UNIXTIME($now)";
...
This avoids any possible issues of timezones, or local date formats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With