600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > PHP 时间戳取整问题

PHP 时间戳取整问题

时间:2019-09-09 18:55:44

相关推荐

PHP 时间戳取整问题

后端开发|php教程

PHP 时间戳取整问题

后端开发-php教程

时间戳是10位的,取的是当前时间戳:

$nowtime = strtotime(date(‘Y-m-d H:i:s’)); //当前时间戳

得到的 $nowtime 有时候是 1393834011,有时候是 1393834062

我想实现一功能,怎么样能让时间戳取整变成这样的:1393834020,1393834070?

不能直接这么写:strtotime(date(‘Y-m-d H:i’));

手机游戏源码生成,mac新建vscode窗口,ubuntu开机流程,tomcat更新服务,sqlite清除数据缓存,微信小程序爬虫登陆,php漂亮的验证码,晋城seo推广咨询,dede查看网站源码,网页显示多个国家时间代码js,微信h5免费模板下载lzw

回复讨论(解决方案)

delphi源码网,联想小新ubuntu 唤醒,买网络爬虫信息,php中午,北京seo策略lzw

<?php

$time=time();

$time=$time/10;

$time_zhengshu=floor($time);

$time_zhengshu=$time_zhengshu*10;

echo “$time_zhengshu”;

?> 不知道这是不是你想要的 测试都是尾数为0.

迪恩母婴源码,如何给ubuntu 扩容,发布tomcat的是旧代码,爬虫判刑多久,jsmin.php中文文档,甘肃网络seolzw

echo round(1393834011 + 9, -1); //1393834020

echo round(1393834062 + 9, -1); //1393834070

float round ( float $val [, int $precision ] )

返回将 val 根据指定精度 precision(十进制小数点后数字的数目)进行四舍五入的结果。precision 也可以是负数或零(默认值)。

楼上+1

<?php

$time=time();

$time=$time/10;

$time_zhengshu=floor($time);

$time_zhengshu=$time_zhengshu*10;

echo “$time_zhengshu”;

?> 不知道这是不是你想要的 测试都是尾数为0. 没看到楼主的需求,以为只是取整。徐版主的答案正确!

floor($time / 10) * 10

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。