Here is a link to the reason for this question: NOW () for transaction DATETIME InnoDB guaranteed?
Thus, to ensure a single transaction with any number of queries (e.g. 20 + ) has a 100% accurate and consistent NOW () value across multiple tables, which php way to assign a variable equivalent to DATETIME using NOW () (not current TIMESTAMP) .
One of the methods:
<?php $nowFormat = date('Ymd H:i:s'); $sql = "INSERT INTO table SET field='$nowFormat'"; $sql2 = "INSERT INTO table SET field='$nowFormat'"; ...
Do it in MySQL, so you don't use PHP at all:
select @now := now(); insert into .... values (@now) select from ... where x=@now etc....
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 problems with time zones or local date formats.
Source: https://habr.com/ru/post/913065/More articles:Does Meteor SockJS use as the main mechanism of interaction between the browser and the server? - websocketiOS - How to selectively delete files older than a month in the Document Directory - iosHow to delete files from iPhone document catalog older than two days - iphoneAPI for Google Docs Viewer - google-docs-apiSQLSTATE [42S22]: column not found: 1054 Unknown column - sqlDelete all files and folder from a specific folder - iphonegcc complains: a variable-sized object cannot be initialized - cWhat are the differences between reversing and a single quote? Can I use an IF statement in a query as above? - phpHow to get the correct values ββfrom a Polar heart rate monitor - javaDisplaying multiple images (slide shows) on the wp installation page under the ProgressGauge panel in Inno Setup - imageAll Articles