Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

strftime

from datetime import datetime

now = datetime.now() # current date and time

year = now.strftime("%Y")
print("year:", year)

month = now.strftime("%m")
print("month:", month)

day = now.strftime("%d")
print("day:", day)

time = now.strftime("%H:%M:%S")
print("time:", time)

date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
print("date and time:",date_time)
Comment

PREVIOUS NEXT
Code Example
Python :: uninstall python linux 
Python :: plotly graph object colorscale 
Python :: how to convert timestamp to date in python 
Python :: qtablewidget clear python 
Python :: query with condition django 
Python :: how to convert a list to dataframe in python 
Python :: takes 1 positional argument but 2 were given python 
Python :: sklearn support vector machine 
Python :: get query param in django 
Python :: fcm_django 
Python :: numpy array with 2 times each value 
Python :: how to scrape multiple pages using selenium in python 
Python :: Python capitalize first letter of string without changing the rest 
Python :: grouped bar chart matplotlib 
Python :: numpy weighted average 
Python :: python plot groupby colors 
Python :: extract one column from dataframe python 
Python :: python - subset dataframe based on unique value of a clumn 
Python :: for loop with enumerate python 
Python :: droping Duplicates 
Python :: how to get input with python 
Python :: Python function to compute factorial of a number. 
Python :: measure time 
Python :: increase axis ticks pyplot 
Python :: try except json decode error 
Python :: python panda append rows to csv python 
Python :: number of days in a month python 
Python :: Python program to implement linear search and take input. 
Python :: python shuffle array 
Python :: python series 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =