[Python] How to extract day, month and year from utcnow?

Discussão em 'Python' iniciado por Stack, Agosto 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following var: time_created = datetime.utcnow()

    How to create a time_created_day var from time_created that will contain only Y, M, d

    like this datetime.datetime(2017, 11, 7)

    I have the following solution:

    from datetime import date

    time_created_day = date(time_created.year, time_created.month, time_created. day)


    is it the best way?

    Continue reading...

Compartilhe esta Página