import pandas as pd
td=pd.Timestamp(1587099167, unit='s',tz='Asia/Kolkata')
print(td)
print(td.value)
Output
2020-04-17 10:22:47+05:30
1587099167000000000
We have used units='s' and time zone as tz='Asia/Kolkata' in above example.
import pandas as pd
td=pd.Timestamp(year=2020,month=12,day=23 , hour=18,minute=20,second=5)
print(td.day)
print(td.asm8)
print(td.dayofweek)
print(td.daysinmonth)
Output
23
2020-12-23T18:20:05.000000000
2
31
Using any date and time
import pandas as pd
td=pd.Timestamp('2020-12-23 18:20:05')
print(td.day)
print(td.asm8)
print(td.weekday())
print(td.dayofweek)
print(td.dayofyear)
Output
23
2020-12-23T18:20:05.000000000
2
2
358
1608747605000000000
5
1608747605.0
import pandas as pd
td=pd.Timestamp('now')
print(td.now('Asia/Kolkata'))
print(td.value)
print(td.second)
print(td.timestamp())
Output
2020-04-19 10:12:42.476310+05:30
1587291162476310000
42
1587291162.47631
dt_my = pd.date_range('2020-12-18 18:15:05', periods=4, freq='D')
#print(dt_my)
df=dt_my - pd.Timestamp("1970-01-01")
print(df.astype(int)/1000000000)
Output
Float64Index([1608315305.0, 1608401705.0, 1608488105.0, 1608574505.0], dtype='float64')
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.