Skip to content

Conversation

@vanigupta20024
Copy link
Contributor

Description

Created snippet to show current date and time in python and explained as well.

A short summary of what is included in your Pull Request.

Fixes #16

Type of change

Choose one or more options from the following as per the nature of your Pull request.

  • NOTE: These boxes can be checked using [X]

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Documentation Update

Checklist:

Please tick all the boxes that are fulfilled by your Pull Request.

  • I have named my files and folder, according to this project's guidelines.
  • My code follows the style guidelines of this project.
  • My Pull Request has a descriptive title. (not a vague title like Update index.md)
  • I have commented on my code, particularly in hard-to-understand areas.

@AdityaJ7 AdityaJ7 self-requested a review October 9, 2020 07:30
# now() method returns current datetime object
cur_time = datetime.datetime.now()

print("Date: ", cur_time.day, "/", cur_time.month, "/", cur_time.year)
Copy link
Member

@AdityaJ7 AdityaJ7 Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use f strings to make it more pythonic
you can use this
print(f"Date: {cur_time.day} / {cur_time.month} / {cur_time.year}")

cur_time = datetime.datetime.now()

print("Date: ", cur_time.day, "/", cur_time.month, "/", cur_time.year)
print("Time: ", cur_time.hour, "h:", cur_time.minute, "m:", cur_time.second, "s")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use f-strings here as well

@vanigupta20024
Copy link
Contributor Author

Done! Thanks for letting me know this, did not know about is earlier!

@AdityaJ7
Copy link
Member

AdityaJ7 commented Oct 9, 2020

Done! Thanks for letting me know this, did not know about is earlier!

No problem.

Nice job with the snippet 👍🏽

@AdityaJ7 AdityaJ7 merged commit 97b3d10 into Python-World:master Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python snippet to check current date and time

2 participants