0

I am trying to do date/time validation in python and I can achieve it using datetime module. My problem is, the data that I get is in epoch format. How do I achieve the same thing by passing epoch format?

My search in python docs has failed me so far. Any tips or leads is much appreciated.

datetime.datetime(year=2017, month=1,day=1) < 
datetime.datetime(year=2017,month=6,day=23,hour=2) >= datetime.datetime.now()
False

datetime.datetime(year=2017, month=1,day=1) < 
datetime.datetime(year=2017,month=6,day=24,hour=2) >= datetime.datetime.now()
True
martineau
  • 119,623
  • 25
  • 170
  • 301
learner
  • 1
  • 1
  • Use [`datetime.datetime.fromtimestamp()`](https://docs.python.org/3/library/datetime.html#datetime.date.fromtimestamp). – martineau Jun 23 '17 at 01:56
  • Or just compare the epoch time to `time.time()`. You don't need to convert it. –  Jun 23 '17 at 02:30

0 Answers0