Using Pandas get current date and time in python
This example illustrates use of pandas to display current date and time. First we need to import pandas module.
## # Python's program to get current date time using pandas. import pandas as pd print(pd.datetime.now()) print(pd.datetime.now().date()) print(pd.datetime.now().year) print(pd.datetime.now().month) print(pd.datetime.now().day) print(pd.datetime.now().hour) print(pd.datetime.now().minute) print(pd.datetime.now().second) print(pd.datetime.now().microsecond)
Sample output of above program.
C:\programs\time>pep8 --first example1.py
C:\programs\time>python example1.py
2018-01-19 16:08:28.393553
2018-01-19
2018
1
19
16
8
28
394553
C:\programs\time>
C:\programs\time>python example1.py
2018-01-19 16:08:28.393553
2018-01-19
2018
1
19
16
8
28
394553
C:\programs\time>
2018-05-15T02:30:00+05:30
2018-05-15T02:30:00+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution