Skip to content
\n

which returns 1 day 6 hours 8 minutes 45 seconds but my question is how can I convert this into a format of e.g. 2022-09-01 12:00:00 instead? Is that possible using Pendulum?

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hi @BarryAljawari - I think you need to make your question more clear. You are creating a pendulum.Duration object (something that represents a length of time), yet you want to display a format that only makes sense for a pendulum.Datetime object (something that designates a particular moment in time).

\n

If you want to explore different ways of turning a duration into a string, have a look at the docs about them: https://pendulum.eustace.io/docs/#properties-and-duration-methods . If you want to convert the Duration into a DateTime, you have to realize that doesn't make sense without more context. That's like saying, I'm going to wait for 4 hours and 52 minutes; express that as a calendar year, month, date, hour and minute.

","upvoteCount":1,"url":"https://github.com/python-pendulum/pendulum/discussions/651#discussioncomment-3612700"}}}
Discussion options

You must be logged in to vote

Hi @BarryAljawari - I think you need to make your question more clear. You are creating a pendulum.Duration object (something that represents a length of time), yet you want to display a format that only makes sense for a pendulum.Datetime object (something that designates a particular moment in time).

If you want to explore different ways of turning a duration into a string, have a look at the docs about them: https://pendulum.eustace.io/docs/#properties-and-duration-methods . If you want to convert the Duration into a DateTime, you have to realize that doesn't make sense without more context. That's like saying, I'm going to wait for 4 hours and 52 minutes; express that as a calendar ye…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BarryAljawari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #649 on September 10, 2022 01:25.