LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Current date conversion to have milliseconds

    Employee
    Posted 12-24-2015 13:33

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: the1don

    I am trying to get the current date time in a specific millisecond format and having issues. I have tried following another post in here and it just isn't coming to me. It is putting the .123000 and not the millisecond time and can't get the PM/AM part. Any help is appreciated

    This is output I would like for the current time it is being run:
    12/24/2015 12:39:32.037626 PM

    This is what I have
    someDate = date()
    someTime = time()
    MS = 123

    someDT = timestamp(someDate, someTime)

    someDTMS = someDT.dateTimeAdjust(MS, "milliseconds")

    emit someDate, someTime, someDT, someDTMS

    someDate someTime someDT someDTMS
    2015-12-24 13:33:37 2015-12-24 13:33:37 2015-12-24 13:33:37.123000


  • 2.  RE: Current date conversion to have milliseconds

    Employee
    Posted 12-28-2015 13:19

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    When you call timestamp(), the datetime object that is created has resolution of milliseconds, but the time that is being pulled from the OS only goes to seconds. So if you cast the datetime object (from 'timestamp()') as a long integer, you'll note that the last three digits are always 0's.

    The easiest way I can think of is using the Python node and using 'strftime' to extract the millisecond portion of the system time.
    Attachments:
    getTime.brg


  • 3.  RE: Current date conversion to have milliseconds

    Employee
    Posted 12-28-2015 14:04

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    To format the datetime in the format you listed above, I would break out the individual components and stitch them together. The AM/PM portion would be calculated.
    Attachments:
    formatDatetTime.brg