How to convert Regular Date to unixtime in Javascript?


How can i convert date which looks like this 12092008 to unixtime like this 1221215809


You may want to use the following:

function covertToUnixTime(yourDate) { return new Date(yourDate.substring(4, 8) + '/' + yourDate.substring(2, 4) + '/' + yourDate.substring(0, 2)).getTime() / 1000; } covertToUnixTime('12092008'); // Returns: 1221170400


You could use jQuery datepicker's <a href="http://jqueryui.com/demos/datepicker/" rel="nofollow">utility</a> functions, parseDate and formatDate.


This worked for me.

var day = $("#day").val(); var month = $("#month").val(); var year = $("#year").val(); var date = new Date(); date.setFullYear(year, month, day) var unixtimeMS = date.getTime(); var unixtime = parseInt(unixtimeMS / 1000); alert(unixtime);


  • Javascript — Unix Time to Specific Time Zone
  • Using JQuery Datepicker To Only Show Months
  • Convert array of strings to array of objects
  • Grouping observations based on first row value
  • Does Perl currently (5.8 and 5.10) make any promises about the order alternations will be used?
  • pyspark substring and aggregation
  • A simple datepicker in VueJS
  • Making more efficient Matlab ismember for large matrices: any faster suggestion than logical indexin
  • How to pull data counter from a website to use in another HTML project as a JS variable
  • How to link 2 Jquery UI datepickers with Knockout?
  • jQuery timepicker 'Object does not support this property or method'
  • Timing loops with asynchronous functions
  • Parallel sieve of Eratosthenes - Java Multithreading
  • Replace last two characters in column
  • DateTime.Today for a specific time zone
  • Doctrine/Symfony entity generator and generating entity from one table
  • Casting between Interfaces and Classes
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Enabling DTD support in Sql Server
  • Convert SQLite database to XML
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • Conversion from string “a” to type 'Boolean' is not valid
  • Row Count Is Returning the incorrect number using RaptureXML
  • Illegal mix of collations for operation for date/time comparison
  • Fill an image in a square container while keeping aspect ratio
  • Release, debug version and Authorization Google?
  • jQuery tmpl and DataLink beta
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Arrays break string types in Julia
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to disable jQuery.jplayer autoplay?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • Hits per day in Google Big Query
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Reading document lines to the user (python)
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?