如何在Javascript中将“常规日期"转换为unixtime?

问题描述:

如何将看起来像12092008的日期转换为unixtime像这样的1221215809

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