Skip to content
Sign upLog in
← Back to Community
Trying to write a function to return today's month, day, and year
Profile icon
stalinbabu

def c_date():
pass

m, d, y = c_date()

How to pass the todays date into the c_date?

print("Today's date is: {:2d}/{:2d}/{:4d}".format(m, d, y))

***********************************************************Tried the following

from datetime import date
dt = date.today()
m = dt.month()
print(m)

#def c_dt():

dt = date.today()

m = dt.month()

d = dt[1:2]

y = dt[:-1]

#c_dt()

#print("Today's date is: {:2d}/{:2d}/{:4d}".format(m, d, y))

Voters
Profile icon
MarkMuchai
Profile icon
stalinbabu
Comments
hotnewtop
Profile icon
AlexanderTarn

import time
t1 = time.time()

this function returns the seconds from New Year 1990, you may find it useful
(It may not be 1990 IDK search Google)

Profile icon
ash15khng

Could you link a repl instead of pasting the code? It's easier to debug with the repl.