python datetime module print 12 hour clock

from datetime import datetime

now = datetime.now()

print(now.strftime('%Y/%m/%d %H:%M:%S')) #24-hour format
print(now.strftime('%Y/%m/%d %I:%M:%S')) #12-hour format

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
python program to get time in 12 hour format python get time 12 hour format python print 12 hour tme get current time in 12 hour format python local time get time in 12 hour format python python current hour in 12 hour format python get hour 12 hour format how to get time in 12 hour format in python current time using python time module 12 hour how to say 24 hour clock python time module how to get current time according to 12 hour clock in python datetime module get current time in 12 hour format python convert from 24 hours to 12 hours in python extract the hour 00-12 format of the time python python datetime module print 12 hour clock print hours that are >12 python python make 12 hours of daytime python convert datetime 12 hour time time in 12 hr pyrhon how to convert 24 hours to minutes in python datetime datetime to 12 hour format python convert timestamp to 12 hour format python python datetime now 12 hour format time object to string python 12 hours format store 24hr time python python convert 24 hour to 12 python get 12 hour time python time 12 am python datetime today 12 hour format re.search 12 hour time from string python 3 datetime time 12 hour python 3 python strftime 12 hour clock convert 24 hours to 12 hours in python without using datetime python time format 12 hour with AM 12 hour time format python cahnge 24 hour time python time python datetime format 12 hour pm python datetime format 12 hour extract 12 hour from datetime python datetime 12 hour format python datetime in 12 hour time python python datetime 12 hour format python convert time to 12 hour python print date and 12` hour time how to show current 12hr time in python python get time in hours not 24 hours extract hour from date in python in 12 hours format python datetime returning 12 hour format from time get 12 format hour python 12 hour time python datetime convert 12 hour datetime to timestamp python datetime module python get hour in 12 hour clock python time format 12 hour print current time in 12 hour format python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source