-4

I can get current time in milliseconds as follows:

import time
timestamp = int(time.time()*1000.0)

However, how can I get the milliseconds of the beginning of today, e.g. 09/09/2018 00:00 ?

Markus
  • 3,562
  • 12
  • 48
  • 85
  • 1
    Before downvoting, dear children, please make some efforts to read the question. – Markus Sep 09 '18 at 15:43
  • got it sir, I have been finding the solutions. tricky one buck of less documentation of time.time() function. – Chandu Sep 09 '18 at 15:45

2 Answers2

0

I hope this works to get the required start of the date's time in milliseconds in Python 3

from datetime import datetime

dt_obj = datetime.strptime('09.09.2019 00:00',
                           '%d.%m.%Y %H:%M')
millisec = dt_obj.timestamp() * 1000

print(millisec)

Output>> 1568001600000.0
Hari_pb
  • 7,088
  • 3
  • 45
  • 53
  • @Markus you need to mention from which day you want . Yes, I hardcoded the date. If you want to automate, you can do that as well with a list of replacement time series. – Hari_pb Sep 09 '18 at 15:51
  • I said `beginning of today, for example ...`. Sorry if it was not clear enough. – Markus Sep 09 '18 at 15:52
0
import pandas as pd
import datetime
int(pd.to_datetime(datetime.datetime.now().date()).value / 1000000)
# Outputs: 1536451200000
Chandu
  • 2,053
  • 3
  • 25
  • 39