惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - shcity

Troubleshooting on TransactionScope Parse string to JSON object blockUI doesn't close when download file in asp.net define namespace in JS Dense_Rank(), Row_Number(), Rank() in sql server reading and writing variable through lock in SSIS script task Fix the issue that cannot open SSIS in BIDS three ways creating custom helpers to show RadioButtonList in MVC using JavaScriptSerializer to serialize object to json using ISerializable to control serialization and deserialization ViewStateAutoManager ReportingService formatting Build my own DataTable split a string into an array through comma div with separated html template - shcity 正则表达式替换日期 半透明的div对话框 foreach 的自动转化类型 在Ajax1.0中调用页面CS文件中的方法
Parse date in js
shcity · 2013-07-09 · via 博客园 - shcity
<script type="text/javascript">
    var str1 = "3/01/2013";
    var str2 = "03/2/2013";

    var d1 = parseDate(str1).getTime();
    var d2 = parseDate(str2).getTime();

    if (d1 == d2) {
        alert("d1 == d2");
    }
    else if (d1 > d2) {
        alert("d1 > d2");
    }
    else {
        alert("d1 < d2");
    }

    function isDate(dateString) {

        var date = parseDate(dateString);

        if (date == null) return false;
        return true;
    }

    function parseDate(dateString) {

        var delimiter = "/";

        if (dateString.indexOf("-") > 0) {
            delimiter = "-";
        }

        var parts = dateString.split(delimiter);

        if (parts.length != 3) {
            return null;
        }

        /* mm/dd/yyyy or mm-dd-yyyy */
        var year = parts[2];
        var month = parts[0] - 1;
        var day = parts[1];

        var newDate = new Date(year, month, day);

        if (isNaN(newDate)) return null;

        if (newDate.getYear() == year
            && newDate.getMonth() == month
            && newDate.getDate() == day) {
            return newDate;
        }

        return null;
    }
</script>

posted on 2013-07-09 16:40  shcity  阅读(401)  评论()    收藏  举报