0

I am using jquery datetime picker and when user selects a value i need user selection to converted into utc timestamp so i that pass that to php webservice using ajax.

Datepicker I am using shows its value in 2014/09/01 11:57 format. Please let me know how i can convert this into utc timestamp in javascript.

Before jquery datetime picker I used to have html5 datetime input elements and i was reading there values using jquery and converting them into UTC timestamp and for that i wrote custom functions. Client asked to use jquery datetime picker and now we are back with this UTC thing.

Najam Awan
  • 1,113
  • 3
  • 13
  • 30

1 Answers1

1
Date.parse("2014/09/01 11:57");

or

new Date("2014/09/01 11:57");

This will create a Date object. You can return the UTC timestamp with the Date object's getTime() or valueOf() functions.

There's a lot of excellent Javascript documentation at the Mozilla Developer Network. The docs for the Date object are here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

Taryn
  • 242,637
  • 56
  • 362
  • 405
Pappa
  • 1,593
  • 14
  • 20