skiboy825
asked on
convert mm/dd/YYYY to timestamp in javascript
How do I convert a date in mm/dd/YYYY format to unix timestamp?
ASKER
thank you, but that function appears to return the next month minus one day.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, works good.
function toUnixStamp(str)
{
var s=str.split("/");
if(s.length>1)return (new Date(Date.UTC(s[2],(s[0]*1 -1),s[1]*1 +1,0,0,0)) .getTime() /1000.0);
}
function toUnixStamp(str)
{
var s=str.split("/");
if(s.length>1)return (new Date(Date.UTC(s[2],(s[0]*1
}
I don't know why, but that function ended up giving me the timestamp for the day before the date I entered. I changed it to fix the problem, but I still don't know why it gave me the wrong day:
function toUnixStamp(str) // Converts mm/dd/yyyy format to Unix timestamp
{
var s=str.split("/");
if(s.length>1)return (new Date(Date.UTC(s[2],(s[0]*1-1),(s[1]*1+1),0,0,0)).getTime()/1000.0);
};
function toUnixStamp(str)
{
var s=str.split("/");
if(s.length>1)return (new Date(Date.UTC(s[2],s[0],s[
}
</script>
<button onclick=alert(toUnixStamp(