Closed f3l1x closed 6 years ago
How is that possible?
imo it's not possible ;) failing testcase needed.
Does it make difference when I use pure
shouldn't.
I make more tests and {default now}
depends on simpleStorageTz, because debugger goes over method convertDateTimeSimpleToSql
.
SimpleStorageTz is by default configured to UTC.
Is it right behaviour?
By documentation:
simple storage time zone – is timezone for column types without automatic timezone conversion; this setting is introduced mainly for backward compatibility, if you migrate from another database abstraction layer, your column values are probably stored in different timezone.
But column $created
is type DateTime
.
what is your column type in db? You are mixing few things, default now does the same thing as new DateTime.
Column type in PostgreSQL is timestamp
. But, in the preview is it showed as formatted date time, e.q. 2014-07-03 09:30:04.097605
.
Any idea?
Did you solve this, or is it still an issue?
Yes I have same problems. Orm save different times to database depends on timezone config. Often I must try different combinations of config.
On some servers works config SimpleStorageTz, but somewhere no.
@honzarac wich column type are you using and what is your orm configuration?
For example on wedos
dbal:
connectionTz: auto-offset # or '+02:00' result is the same
driver: mysqli
host: wm123.wedos.net
database: ***
username: ***
password: ***
Column type is always date or datetime
From phpinfo()
Default timezone Europe/Prague
in database 2017-04-15 18:56:22
on web 2017-04-15 20:56:22
@honzarac could you please debug what is returned here? https://github.com/nextras/orm/blob/5f64787e99d4ee82f56d758a80d412bf4d848afd/src/Mapper/Dbal/StorageReflection/StorageReflection.php#L301
e,g, what returns $this->platform->getColumns($this->storageName)
, there may be a problem with the above defined $types which camelcase :X
last_action_time => array (8)
name => "last_action_time" (16)
type => "DATETIME" (8)
size => NULL
default => NULL
is_primary => FALSE
is_autoincrement => FALSE
is_unsigned => FALSE
is_nullable => TRUE
$types
array (1)
DATETIME => TRUE
The original @f3l1x issue is that he used a wrong type in db, timestamp doesn't have timezone handling.
The same seems to be for @honzarac who uses datetime
instead of timestamp
.
Current version of Dbal & Orm has better support for this and it should not do such damage. Both guys, you should try it.
Please, also double check documentation how timezone works :) (works in current Dbal) https://nextras.org/dbal/docs/3.0/datetime
Neon config:
If entity has column
DateTime $created
with macro annotation{default now}
. I found in database time 10:00.If entity does not have an annotation
{default now}
and I set date manually via$e->created = new DateTime()
. Time is correct.How is that possible?
Does it make difference when I use pure
\DateTime
,Nette\Utils\DateTime
orNextras\Dbal\Utils\DateTime
?Thanks.