English 中文(简体)
PHP 的确切日期
原标题:PHP redirect on exact date

采用该守则的Im,根据该周的小时和日子进行转播。

这里是。

<?php

$hour = date( G );
$minute = date( i );
$day = date( w );
$m = $hour * 60 + $minute; // Minutes since midnight.

if (
  $day == 0    // Sunday...
  && $m >= 615 // ... after 10:15…
  && $m <= 700 // ... but before 11:40…
) {
  header("Location: open.php");
}
else
if (
  $day == 3     // Wednesday...
  && $m >= 1125 // ... after 18:45…
  && $m <= 1235 // ... but before 20:35…
) {
  header("Location: open.php");
}

?>

我很想知道,是否有办法根据今后4月25日或11月1日这一确切日期改用一页。

感谢。

最佳回答

这是一种简单的做法,没有考虑到该年的日期:

// 25th april:
if (date( d ) ==  25  && date( m ) ==  4 ) {
  header( Location: open.php );
}
// 1st nov:
if (date( d ) ==  1  && date( m ) ==  11 ) {
  header( Location: open.php );
}

查阅日()文件,以便了解更准确的细节。

问题回答

利用<代码>strtotime(>或date(<>)将改头日期改为时间序列,而且你可以轻易这样做。

if(strtotime("2012/5/3") <= time()) {
     header("location: toredirect.php");
     exit;
}

Sure.

$date = date();
$redirectDate = Date here;

if($date == $redirectDate) {
    header("Location: open.php");
}

这将基于你的服务器日期/时间。





相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签