I am getting time using the following code, if I print this value I am getting month, date, year and also the H, M, S. I just need MM/DD,YEAR, how do I get it?
lastTime = datetime.datetime.strptime(timeStr, "%m/%d/%Y %H:%M:%S")
print lastTime
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To print the datetime in the format
MM/DD,YEAR:If you want the date in the format
MM-DD-YEAR, use:Also note
lastTimeis a datetime.datetime object. The month, day and year are accessible through attributes: