Skip to content

Instantly share code, notes, and snippets.

@GongLe
Last active December 19, 2015 13:48
Show Gist options
  • Select an option

  • Save GongLe/5964267 to your computer and use it in GitHub Desktop.

Select an option

Save GongLe/5964267 to your computer and use it in GitHub Desktop.
javascript转换日期字符串为Date对象
/**
日期格式字符串转为Date.getTime对象
@param str 日期格式字符串
@return Date time
<p>
eg: string2Date(2013-07-13 10:00:00' ) -> 1373700600000
</p>
**/
function string2Date(str){
return (new Date(Date.parse(str.replace(/-/g, "/")))).getTime() ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment