Skip to content

How to assign to a new variable the current time using time::PrimitiveDateTime type? #507

Closed Answered by jhpratt
frederikhors asked this question in Question
Discussion options

You must be logged in to vote

To get the current time, you have to use OffsetDateTime — specifically OffsetDateTime::now_utc or OffsetDateTime::now_local. This is because Instant is opaque and PrimitiveDateTime has no time zone or UTC offset — something necessary to indicate a specific point in time.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by frederikhors
Comment options

You must be logged in to vote
3 replies
@jhpratt
Comment options

@Kinrany
Comment options

@jhpratt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants