I would like to adjust the "[% format_date( now(),'dd/MM/yyyy HH:mm:ss') %]", as it currently displays 07/12/2020 13:31:40 on the map, as I am in the UK right now. However, I would like to change the time to fit time zone that is 6 hours behind me (a South American country). Is there any way I can do this?

map_label = QgsLayoutItemLabel(layout)
map_label.setText("[% format_date( now(),'dd/MM/yyyy HH:mm:ss') %]")
map_label.setFont(QFont("Arial", 18))
map_label.attemptMove(QgsLayoutPoint(40, 33, QgsUnitTypes.LayoutMillimeters))
map_label.attemptResize(QgsLayoutSize(143, 120, QgsUnitTypes.LayoutMillimeters))

1 Answer 1


I did not find a function for adding hours to a date so here's a workaround expression:

format_date(make_datetime(year(now()), month(now()), day(now()), hour(now()) - 6, minute(now()), second(now())),'dd/MM/yyyy HH:mm:ss')

  • Thank you very much for your help. It works perfectly fine
    – LiamHems
    Dec 7, 2020 at 14:30
  • Would you also know by any chance how to add a label that contains a value within an attribute table? For example, I have a vector point and within the attribute table, I have a column called magnitude and would like to display this magnitude as a label on the map. Thanks
    – LiamHems
    Dec 7, 2020 at 14:32
  • If the expression has the layer context then simply use "magnitude" in the expression Dec 7, 2020 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.