zoukankan      html  css  js  c++  java
  • 字符串轉換成日期(Object)

    function StringToDate(sDate)
    {
                    // Parameters :
    // sDate : A string with the format "mm/dd/yyyy" or "mm/dd/yyyy hh:mm:ss"
    // Returns : a Date object

    if (sDate =="")
    {
       sDate="01/01/2040";
    }

    var ArDateTime = sDate.split (" ");
    var ArDate = ArDateTime[0];
    var splitDate = ArDate.split ("/");
    var nDay = ToNumber(splitDate[1]);
    var nMonth = ToNumber(splitDate[0]);
    var nYear = ToNumber(splitDate[2]);
    if (ArDateTime.length == 1)
          return (new Date(nYear, nMonth-1 , nDay))
    else
    {     var ArTime = ArDateTime[1];
           var splitTime = ArTime.split(":");
           if (splitTime[0]=="00" && splitTime[1]=="00" && splitTime[2]=="00" )
                 return (new Date(nYear, nMonth-1 , nDay))
           else
           {
                 var nHours     = ToNumber(splitTime[0]);
                 var nMinutes   = ToNumber(splitTime[1]);
                 var nSeconds = ToNumber(splitTime[2]);
                 return (new Date(nYear,nMonth-1,nDay, nHours, nMinutes, nSeconds))
           }
    }

    }

  • 相关阅读:
    tomcat解压版环境变量配置
    十天冲刺(第二阶段)
    十天冲刺(第二阶段)
    十天冲刺
    十天冲刺第二阶段()
    十天冲刺(第二阶段)
    十天冲刺(第二阶段)
    十天冲刺(第一阶段)
    十天冲刺(第一阶段)
    十天冲刺(第一阶段)
  • 原文地址:https://www.cnblogs.com/guyuehuanhuan/p/1899670.html
Copyright © 2011-2022 走看看