js怎么定义日期类型

JavaScript026

js怎么定义日期类型,第1张

是获取时间吗?

建议用Calendar类

Date有两个,并且有很多过时的方法

小DEMO:

import java.util.Calendar

public class Test{

public static void main(String[] args) {

Calendar cal=Calendar.getInstance()

System.out.println(cal.get(Calendar.YEAR))

System.out.println(cal.get(Calendar.MONTH)+1)//月份要加1

System.out.println(cal.get(Calendar.DAY_OF_MONTH))

}

}

额```刚才看错了`上面是JAVA的`下面是JS的:

<HTML>

<HEAD>

<TITLE>New Document </TITLE>

<META NAME="Generator" CONTENT="EditPlus">

<META NAME="Author" CONTENT="">

<META NAME="Keywords" CONTENT="">

<META NAME="Description" CONTENT="">

<SCRIPT LANGUAGE="JavaScript">

<!--

var da=new Date()

alert(alert(da.getYear()+"-"+da.getMonth()+1+"-"+da.getDate())

//-->

</SCRIPT>

</HEAD>

<BODY>

</BODY>

</HTML>

<script type="text/javascript">

var end_time = <?php echo $end_time ?>

...

</script>