English 中文(简体)
PHP选择目前囚室的时间
原标题:PHP select current time in cell
  • 时间:2010-09-09 20:19:59
  •  标签:
  • php

如果我使用购买力平价法,那么:

for ($i = 1; $i <= 24; $i++)
 {
 $timetable=strftime("%X", mktime(0, 0, $hour[$i], $month, $day, $year));
 }

to:

   time   |
 ----------
 05:09:23 |
 ----------
 07:23:18 |
 ----------
 11:55:41 |
 ----------
 14:01:32 |
 ----------

我愿强调,印刷时间包括目前时间的单位(如果目前时间为9:23:00亮点将是一个印刷时间为7:23:18的电池,如果目前时间为13:59:06亮点将为11:55:41)

我如何能够这样做?

最佳回答

利用这一方法:

$thisID = 0;
for ($i = 1; $i <= 24; $i++)
{
    $tt = mktime(0, 0, $hour[$i], $month, $day, $year);
    $timetable = strftime("%X", $tt);

    if($thisID == 0 && (time() - $tt) >= 0)
         $thisID = $i;
}

现在$thisID给你必要的行文。 利用它来强调行文。

问题回答

我认为,最好的办法是从午夜把时间存放在不完美的营地或秒钟。 这样,你就掌握了数据。

为了获得最贴近的记录,你需要回答2个问题。

Select time from times where time > $value order by time desc limit 1
Select time from times where time < $value order by time asc limit 1

现在,将这两笔结果与价值比较,并交还最接近的数额。

尽管这种方法需要2个查询,并且使用比发言大或少,但我认为理论比检索所有数据更快。

希望这一帮助!





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签