Python Forum
Help with tomorrow's date please
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with tomorrow's date please
#1
I am using this:

localtime = time.asctime( time.localtime(time.time()) )
It returns this: Sun Apr 1 10:52:03 2018

How do I return tomorrow's day, month and date (the time and year aren't used) in the same format?
Thanks.
Reply
#2
>>> from datetime import datetime, timedelta
>>> tomorrow = datetime.now() + timedelta(days=1)
>>> tomorrow
datetime.datetime(2018, 4, 2, 12, 53, 23, 424183)
At this point, you have a datetime object, and you can use its strftime() method to format it in whatever way you prefer.
You can take a look at https://docs.python.org/3/library/dateti...e-behavior for more information about that.
Reply
#3
This is another good source for examples: https://pymotw.com/3/datetime/
Reply
#4
Sorted, thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 127 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 518 Jan-20-2024, 04:45 AM
Last Post: 1418
  Date format and past date check function Turtle 5 4,076 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  How to add previous date infront of every unique customer id's invoice date ur_enegmatic 1 2,191 Feb-06-2021, 10:48 PM
Last Post: eddywinch82
  How to add date and years(integer) to get a date NG0824 4 2,806 Sep-03-2020, 02:25 PM
Last Post: NG0824
  Substracting today's date from a date in column of dates to get an integer value firebird 1 2,101 Jul-04-2019, 06:54 PM
Last Post: Axel_Erfurt
  How to change existing date to current date in a filename? shankar455 1 2,273 Apr-17-2019, 01:53 PM
Last Post: snippsat
  Date format conversion "/Date(158889600000)/" lbitten 2 2,790 Nov-29-2018, 02:14 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020