1

I am currently writing a discord bot, and I want to be able to print today's date as dd/mm/yyyy. I tried .strftime() and .strpdate() but I can't find out a way to incorporate .now().

import time, datetime
from datetime import datetime

@commands.command()
async def date(self, ctx):
    await ctx.send(datetime.now().strpdate('%d:%m:%Y'))

This is the output:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'datetime.datetime' object has no attribute 'strpdate'

Kai
  • 115
  • 1
  • 2
  • 7
  • does this answer your question? https://stackoverflow.com/questions/30071886/how-to-get-current-time-in-python-and-break-up-into-year-month-day-hour-minu – James Powis Jul 07 '20 at 00:04

1 Answers1

2
from datetime import datetime
datetime.now().strftime('%d:%m:%Y')
'06:07:2020'
James Powis
  • 609
  • 4
  • 16