0

I have my date and time field in the form Timestamp('2016-12-02 22:25:44'). I want this to be converted to integer millisecond form in python. Any suggestion how to do this?

Bineeta Saikia
  • 99
  • 1
  • 1
  • 6
  • What's `Timestamp`? – chepner Jul 19 '18 at 14:22
  • 1
    What do you mean by "integer millisecond form"? Can you give an example of the output? – Joel Jul 19 '18 at 14:23
  • 1
    Like milliseconds since 1970 or some epoch? – doctorlove Jul 19 '18 at 14:23
  • Is that your value a string `Timestamp('2016-12-02 22:25:44')` or a timestamp object with datetime '2016-12-02 22:25:44'? – SnowBG Jul 19 '18 at 14:24
  • Welcome to stackoverflow. Please edit your question to include a clear problem description and if possible some minimal code. For guidance please check the [how to ask](https://stackoverflow.com/help/how-to-ask) page and [how to create a minimal example](https://stackoverflow.com/help/mcve). – 5th Jul 19 '18 at 14:29

1 Answers1

0

Python is quite good at this. The following function worked for me in many cases.

from dateutil.parser import parse
parse('2016-12-02 22:25:44').strftime("%s")

(just read the comments, thought you meant a string, not sure if this answer applies to what you ask but seems not clear yet)

vladmihaisima
  • 2,119
  • 16
  • 20