Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get time and dates string


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 :: get index of first true value numpy 
Python :: python code for internet radio stream 
Python :: python dict items 
Python :: reverse a list in python 
Python :: python sort a list using defined order 
Python :: how to generate python code 
Python :: .translate python 
Python :: python qr scanner 
Python :: create a dictionary from index and column pandas 
Python :: neat way to print 2d array 
Python :: delete from table django 
Python :: python test coverage 
Python :: dictionary multiple values per key 
Python :: remove rows from dataframe 
Python :: pandas excel writer append in row 
Python :: recurrent neural network pytorch 
Python :: flask flash The browser (or proxy) sent a request that this server could not understand. 
Python :: How to check the number of occurence of each character of a given string in python 
Python :: global var in python 
Python :: creating a dictionary 
Python :: web scraping with selenium 
Python :: when to use finally python 
Python :: python write float with 2 decimals 
Python :: fibonacci sequence 
Python :: access list index python 
Python :: Python Pandas: Create new column out of other columns where value is not null 
Python :: python import statement 
Python :: map dataframe 
Python :: WARNING: Ignoring invalid distribution c program files python39libsite-packages 
Python :: fastest way to iterate dictionary python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =