6 examples of 'python date format yyyymmdd' in Python

Every line of 'python date format yyyymmdd' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
46def date(__format):
47 d = datetime.datetime.utcnow()
48 return d.strftime(__format)

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

123def fmt_date(date: datetime.datetime) -> str:
124 return datetime.datetime.strftime(date, '%Y-%m-%dT%H:%M:%S')
3def ymd():
4 from datetime import datetime
5 return datetime.today().strftime('%Y%m%d')
395def format_date(d, dateformat="%Y-%m-%d"):
396 """
397 Formats a python date to the format given (strftime rules)
398 """
399 if d is None: return ""
400 try:
401 return time.strftime(dateformat, d.timetuple())
402 except:
403 return ""
43def FormatDate(date, format=None):
44 ms = int(date[6:-7])
45 date = datetime.datetime.fromtimestamp(ms/1000.0)
47 if format:
48 return datetime.datetime.strftime(date, format)
49 else:
50 return date
13def get_daystr_format(data):
14 datastr = data.strftime("%Y-%m-%d %H:%M:%S")
15 return datastr

Related snippets