0

I started to use the React-datetime component and I have the next command:

  <Datetime style = {dateTimePickerCSS} dateFormat='YYYY-MM-DD' timeformat='hh-mm-ss' onChange={(value) => this.setState({modalWLStart: value})} />

if I select '2017-07-12 12:00 AM' then for value I get 1499839200000 but I wish I could get the output as:

2017-07-12 12:00:00

not using AM or PM so I can send the value to a mysql DB. Is this possible? how?

One more question, how are values like 1499839200000 related to dates?

Can you please let me know? thanks

Jose Cabrera Zuniga
  • 2,348
  • 3
  • 31
  • 56

1 Answers1

0

1499839200000 is the Unix timestamp. I suspect something went wrong where your date data comes.

I used this little script transfer it into regular formate

    var unix_timestamp = 1493416620000;

    var date = new Date(unix_timestamp*1000);
    // Hours part from the timestamp
    var hours = date.getHours();
    // Minutes part from the timestamp
    var minutes = "0" + date.getMinutes();
    // Seconds part from the timestamp
    var seconds = "0" + date.getSeconds();

    // Will display time in 10:30:23 format
    var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);

    console.log(formattedTime);
Yuhao
  • 147
  • 9