Monday 15 June 2015

datapicker - datepicker convert to timestamp keeping format for display -


I have the following calendar script (jQuery) and it works. Next I would like to save the user selection to the database. The database has been filed: Timestamp.

I have to keep the current date format found in the script to display in the input field for the user's readability, but in the background I want to convert it to a timestamp so that I can save it to the database How do I change it in a timestamp?

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ("# date"). {{ShowButtonPanel: true, minDate: '0M', maximum date: '+ 90D', date format: "d-MM-yy ",});}); & Lt; / Script & gt; & Lt; P & gt; Enter project end date: & lt; Input type = "text" name = "date" id = "date" /> gt; & Lt; / P & gt; Use    

to convert the string to a JavaScript date. You can call () when you get to get milliseconds from January 1, 1970. Divide by 1000 to get a UNIX timestamp.

  var dateString = $ ('# date'). Val (); Var timestamp = date.pars (datestring) .getTime () / 1000;    

No comments:

Post a Comment