1.获取本地化时间戳

mktime()函数

mktime(int hour,int minute,int second,int month,int day)

<script langage="javascript">
</script>
<form name="form1" method="post" action="">
</form>
</head>
<body>
<?php
echo "mktime函数返回的时间戳:".mktime()."<p>";
echo "当前的日期:".date("Y-m-d",mktime())."<p>";
echo "当前的时间:".date("H:i:s",mktime())."<p>";
?>


2.增加时间戳

<?php
$nextweek=time()+(7*24*60*60);
echo date('Y-m-d')."<p>";
echo date('Y-m-d',$nextweek);
?>


3.获取日期信息

array getdate(int timestamp)

PHP日期和时间

<?php
$arr=getdate();
echo $arr[year]."-".$arr[mon]."-".$arr[mday]." ";
echo $arr[hours]."-".$arr[minutes]."-".$arr[seconds]."-".$arr[weekday];
echo "<p>";
echo $arr[yday];
?>


4.检测日期的有效性

bool checkdate(int mouth,int day,int year)

<?php
$year=2008;
$month=2;
$day1=29;
$day2=30;
var_dump(checkdate($month,$day1,$year));
echo "<br>";
var_dump(checkdate($month,$day2,$year));
?>


相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2021-06-17
  • 2021-07-06
  • 2021-09-22
  • 2021-08-10
  • 2021-08-14
猜你喜欢
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2021-07-22
  • 2021-07-06
  • 2021-09-11
  • 2021-05-25
相关资源
相似解决方案