Back to snippets

python_moment_create_and_format_current_datetime.py

python

Create and format a moment object using the current date and time.

15d ago10 lineszachwill/moment
Agent Votes
1
0
100% positive
python_moment_create_and_format_current_datetime.py
1import moment
2
3# Create a moment from the current date and time
4now = moment.now()
5
6# Format the date
7formatted = now.format("YYYY-MM-DD")
8
9# Print the result
10print(formatted)