Skip to main content
Fixed docs link
Source Link
Robin Schambach
  • 19.8k
  • 1
  • 20
  • 45

In Craft 2 the date would be converted to a string automatically. You need to do this explicitly in Craft 3. For exampleconvert the DateTime object via Filter:

 now|date('U') 

or via function

now.format('U')

This will format the date as a UNIX timestamp which is sufficient for querying. MySQL datetime format will work too: date('Y-m-d H:i:s')

More info can be found in the upgrade documentation.

In Craft 2 the date would be converted to a string automatically. You need to do this explicitly in Craft 3. For example:

 now|date('U') 

This will format the date as a UNIX timestamp which is sufficient for querying. MySQL datetime format will work too: date('Y-m-d H:i:s')

More info can be found in the upgrade documentation.

You need to convert the DateTime object via Filter:

 now|date('U') 

or via function

now.format('U')

This will format the date as a UNIX timestamp which is sufficient for querying. MySQL datetime format will work too: date('Y-m-d H:i:s')

More info can be found in the upgrade documentation.

Please readIn Craft 2 the docsdate would be converted to a string automatically. You need to do this explicitly in Craft 3. For example:

 'now'|datenow|date('U') 

Is what you want usually formattedThis will format the date as a UNIX timestamp date('U') or as mysqlwhich is sufficient for querying. MySQL datetime format will work too: date('Y-m-d H:i:s')

More info can be found in the upgrade documentation.

Please read the docs

 'now'|date() 

Is what you want usually formatted as timestamp date('U') or as mysql datetime format date('Y-m-d H:i:s')

In Craft 2 the date would be converted to a string automatically. You need to do this explicitly in Craft 3. For example:

 now|date('U') 

This will format the date as a UNIX timestamp which is sufficient for querying. MySQL datetime format will work too: date('Y-m-d H:i:s')

More info can be found in the upgrade documentation.

Source Link
Robin Schambach
  • 19.8k
  • 1
  • 20
  • 45

Please read the docs

 'now'|date() 

Is what you want usually formatted as timestamp date('U') or as mysql datetime format date('Y-m-d H:i:s')