[Python] how to convert datetime object to time_ns

Discussão em 'Python' iniciado por Stack, Outubro 2, 2024.

  1. Stack

    Stack Membro Participativo

    I have the following problem I need to convert some datetime object to time_ns (present in time)

    all I can find is to convert the now datetime to that fixed nanoseconds number (i understand that it is calculated from a fixed date in 1970)

    import time
    now = time.time_ns()


    all I want is to convert some normal datetime object to that fixed nanoseconds number

    from datetime import datetime
    x = datetime(2022, 2, 22, 15, 41, 50)


    i don't want to be restricted to only now dates. is there some function in the library that does that? for the moment i cannot find anything

    thank you very much

    Continue reading...

Compartilhe esta Página