osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I get datetime to stop showing seconds?


Right on target, 
Many Thanks....


FootNote:
If money does not grow on trees, then why do banks have branches?

-----Original Message-----
From: Python-list <python-list-bounces+gronicus=sga.ninja at python.org> On
Behalf Of Frank Millman
Sent: Friday, October 16, 2020 4:34 AM
To: python-list at python.org
Subject: Re: How do I get datetime to stop showing seconds?

On 2020-10-16 9:42 AM, Steve wrote:
> d2 =  datetime.datetime.now() #Time Right now
> 
> Show this: 2020-10-16 02:53
> and not this: 2020-10-16 02:53:48.585865
> 

 >>>
 >>> str(d2)
'2020-10-16 10:29:38.423371'
 >>>
 >>> d2.strftime('%Y-%m-%d %H:%M')
'2020-10-16 10:29'
 >>>


Frank Millman
-- 
https://mail.python.org/mailman/listinfo/python-list