[Python] Unable to get the correct year for a UTC timestamp [closed]

Discussão em 'Python' iniciado por Stack, Novembro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to get a year and time in UTC format. I am able to print the time in the desired format but it is always printing the wrong year. I am not sure if it prints the correct time:

    start_value: 2024-06-05 10:50:42

    Target value: 300,150 seconds from the start_value

    Actual value: 1970-01-04 13:22:30

    It should print the value 300,150 seconds far from the start_value in the format 2024-06-05 HH-MM-SS.

    What I tried:

    from datetime import datetime

    start_time=[300150]
    dt_time = datetime.datetime.fromtimestamp(300150).strftime('%Y-%m-%d %H:%M:%S')
    print(dt_time)


    How would it know where it needs to take the year information from?

    Continue reading...

Compartilhe esta Página