导航:首页 > 编程语言 > php当前时间加分钟

php当前时间加分钟

发布时间:2022-07-05 22:57:23

php 怎么计算当前小时还剩余多少分钟

将需要计算的两个时间转换成时间戳
,php的时间戳就是以秒为单位计算的,两个时间戳相减的结果就是相差的秒数咯

㈡ php当前时间夹30分钟

<?php
/*
* author: china_skag
* time: 2014-07-08
* 发博时间计算(年,月,日,时,分,秒)
* $createtime 可以是当前时间
* $gettime 你要传进来的时间
*/
class Mygettime{
function __construct($createtime,$gettime) {
$this->createtime = $createtime;
$this->gettime = $gettime;
}
function getSeconds()
{
return $this->createtime-$this->gettime;
}
function getMinutes()
{
return ($this->createtime-$this->gettime)/(60);
}
function getHours()
{
return ($this->createtime-$this->gettime)/(60*60);
}
function getDay()
{
return ($this->createtime-$this->gettime)/(60*60*24);
}
function getMonth()
{
return ($this->createtime-$this->gettime)/(60*60*24*30);
}
function getYear()
{
return ($this->createtime-$this->gettime)/(60*60*24*30*12);
}
function index()
{
if($this->getYear() > 1)
{
if($this->getYear() > 2)
{
return date("Y-m-d",$this->gettime);
exit();
}
return intval($this->getYear())." 年前";
exit();
}
if($this->getMonth() > 1)
{
return intval($this->getMonth())." 月前";
exit();
}
if($this->getDay() > 1)
{
return intval($this->getDay())." 天前";
exit();
}
if($this->getHours() > 1)
{
return intval($this->getHours())." 小时前";
exit();
}
if($this->getMinutes() > 1)
{
return intval($this->getMinutes())." 分钟前";
exit();
}
if($this->getSeconds() > 1)
{
return intval($this->getSeconds()-1)." 秒前";
exit();
}
}
}
//类的使用实例
/*
*
* 调用类输出方式
*
* $a = new Mygettime(time(),strtotime('-25 month'));
* echo iconv('utf-8', 'gb2312', $a->index())?iconv('utf-8', 'gb2312', $a->index()):iconv('utf-8', 'gb2312', '当前');
*
*/

㈢ php中如何获得当前时间

一、使用函式 date() 实现

在编辑器中输入<?php echo $showtime=date("Y-m-d H:i:s");?>,点击回车就可以得知当前的时间。其中Y是代表4位的年份,H是24小时制,i 是分钟,如: "00" 至 "59" 。s -是秒,如: "00" 至 "59" 。

d 是几日,二位数字,若不足二位则前面补零。 如: "01" 至 "31" 。m代表月份,二位数字,若不足二位则在前面补零,如: "01" 至 "12" 。

二、使用time函数

在编辑器中输入echo date("y-m-d",$time)点击回车就可以得知当前的时间,其中Y是代表4位的年份,m代表月份,二位数字,若不足二位则在前面补零,如: "01" 至 "12" 。d 是几日,二位数字,若不足二位则前面补零。 如: "01" 至 "31" 。

三、使用strftime函数

在编辑器中输入echo strftime ("%hh%m %a %d %b" ,time());点击回车就可以得知当前的时间。

(3)php当前时间加分钟扩展阅读:

Date/Time 函数

一、time — 返回当前的 Unix 时间戳

二、timezone_abbreviations_list — 别名 DateTimeZone::listAbbreviations

三、timezone_identifiers_list — 别名 DateTimeZone::listIdentifiers

四、timezone_location_get — 别名 DateTimeZone::getLocation

五、date — 格式化一个本地时间/日期

六、getdate — 取得日期/时间信息

七、gettimeofday — 取得当前时间

八、gmdate — 格式化一个 GMT/UTC 日期/时间

九、gmmktime — 取得 GMT 日期的 UNIX 时间戳

㈣ php 时间相加

$a=time();//获取当前时间戳
$b=strtotime("+7days",$a);//获取在以$a时间戳为基础的七天后的时间戳

//注意,以上获取的都是时间戳,strtotime()也要用时间戳,若想转转为阁下下用的那种显示方式,应该再用date函数转换
echodate("Y-m-d",$a);
echo"</br>";
echodate("Y-m-d",$b);

㈤ PHP怎么获取当前时间

要设置时区,PHP默认的不是中国的时区,是格林威治时间。所以设置一下时区就可以搞定!<?php
date_default_timezone_set('Etc/GMT-8'); //这里设置了时区
echo date("Y-m-d H:i:s");
?>

㈥ php 时间加减

<?php
echo "今天:",date('Y-m-d H:i:s'),"<br>";
echo "明天:",date('Y-m-d H:i:s',strtotime('+1 day'));
?>
上一行输出当前时间,下一行输出明天时间

这里+1 day
可以修改参数1为任何想需要的数 day也可以改成year(年),month(月),hour(小时),minute(分),second(秒)

date('Y-m-d H:i:s',strtotime("+1 day +1 hour +1 minute");
可以随便自由组合,以达到任意输出时间的目的
注:该方法之针对1970年以后试用,也就是时间戳的适用范围。

php 常用日期相函数[日期加减,两日期之差,日期转换时间截]

下面这些代码是一些常用的日期处理函数了,可以两个时间的日期加减,两日期之差,日期转换时间截等。

echo date('Y-m-d',strtotime('+1 d',strtotime('2009-07-08')));//日期天数相加函数

echo date("Y-m-d",'1246982400');
echo '<br>';
echo date("Y-m-d",'1279123200');
die();

$d = "2009-07-08 10:19:00";
echo date("Y-m-d",strtotime("$d +1 day")); //日期天数相加函数

function dateToTime($d)//把日期转换成时间堆截
{
$year=((int)substr("$d",0,4));//取得年份

$month=((int)substr("$d",5,2));//取得月份

$day=((int)substr("$d",8,2));//取得几号

return mktime(0,0,0,$month,$day,$year);
}

/*

下面函数计算两日期之差

*/

$Date_1="2009-07-08";

echo $Date_1+1;

$Date_2="2009-06-08";
$Date_List_a1=explode("-",$Date_1);

$Date_List_a2=explode("-",$Date_2);

$d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);

$d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);

$Days=round(($d1-$d2)/3600/24);

echo "两日期之前相差有$Days 天";

㈦ php按时分时间段判断语句

临时写了一段,你看看,

<?php

date_default_timezone_set('PRC');//设置时区,其中PRC为“中华人民共和国”

$j=date("H:i");获得当前小时和分钟的时间
$h=strtotime($j);//获得当前小时和分钟的时间时间戳
$z=strtotime('00:00');//获得指定分钟时间戳,00:00
$x=strtotime('00:29');//获得指定分钟时间戳,00:29
if($h>$z&&$z<$x){
echo'显示时间是00:00到00:29分之间';
}
?>

㈧ PHP 时间 加上 时 分 秒

$S=rand(0,23);//随机--时
$F=rand(0,59);//随机--分
$M=rand(0,59);//随机--秒

$coupon_start_time=strtotime(date('Y-m-d')."$S:$F:$M");//给这个上加上“$S,$F,$M”
$coupon_end_time=strtotime(date('Y-m-d',strtotime('+30day'))."$S:$F:$M");//给这个也上加上“$S,$F,$M”

㈨ 求一个简单的php时间变量

functiont(){
date_default_timezone_set('Asia/Shanghai');
$h=date('H',$_SERVER['REQUEST_TIME']);
$m=date('i',$_SERVER['REQUEST_TIME']);
return$h.'-'.(strlen($m)>1?substr($m,0,1):'0');
}

如果分钟不足10分钟,返回的是0

时区设置的是上海的,你可以根据需求自己改

㈩ php 如何对time类型的时间进行加减如11:20:30加20分钟

把这个时间转换成时间戳,然后把20分钟换算成秒数,然后与时间戳相加,再用函数把新得到的时间戳转换成时间

阅读全文

与php当前时间加分钟相关的资料

热点内容
编译程序输入一个字符串 浏览:402
圆命令画法 浏览:303
如果给电脑e盘文件加密 浏览:801
javaswing项目 浏览:774
androidsdksetup 浏览:1003
pdf怎么设置中文 浏览:126
安卓手机用什么软件看伦敦金 浏览:962
魅族文件夹无名称 浏览:789
苏黎世无人机算法 浏览:872
核桃编程和小码王的融资 浏览:684
微积分教材pdf 浏览:725
写python给微信好友发消息 浏览:336
蚊帐自营米加密 浏览:418
学校推荐核桃编程 浏览:804
湖南农信app怎么导明细 浏览:471
福特abs编程 浏览:508
如何自学安卓手机 浏览:439
以太坊源码共识机制 浏览:910
单片机探测器 浏览:872
demo编程大赛作品怎么运行 浏览:52