1
PHP:
$date = new DateTime();
print_r ($date);
outworking:
DateTime Object ( [date] => 2017-11-07 15:51:26.000000 [timezone_type] => 3
[timezone] => America/Sao_Paulo )
OK so far.
Database (sql). Table "extras":
I need to know which pattern the datetime type uses, to know how to post the date and time information in the bank.
Below the tests performed, and the responses obtained:
TEST 1:
$postdate = $conect -> query("INSERT INTO extras (data) values ('{$date['date']}')");
TEST 2:
$postdate = $conect -> query("INSERT INTO extras (data) values ('{$date}')");
Ever since I thank
have to modify to USA date mode to enter into Y-m-d database, correct @rray ?
– user92870
Yes, you can just use
$data = date('Y-m-d H:i:s');
– rray
I think there’s something not getting into my head. If I use "$data = date('Y-m-d H:i:s');", when I retrieve the information it will be just any string. To use it like this wouldn’t make a difference using datetime, or a varchar.
– ARodrigues
vc do not need to write a php Datetime object to the database, if it is recorded as varchar it will not sort or search the results correctly. Relacioanda: Varchar or Datetime?
– rray