<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[[实践OK]php的round函数实现将微秒转换为毫秒]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Sat, 09 Mar 2024 12:20:44 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	<br/>$date = microtime(true);// 返回浮点数，小数点前面是当前时间的时间戳，小数点后为当前时间的微秒<br/>var_dump($date);<br/>// 输出：float(1566897763.0927)<br/><br/><br/><br/>PHP的round函数用于四舍五入浮点数。它的作用是返回最接近一个数字的整数，也可以指定小数点后的位数。例如：<br/><br/>$float = 3.14159;<br/>$rounded = round($float, 2); // 返回 3.14<br/>$rounded = round($float); // 返回 3<br/><br/><br/>要求：timestamp 时间戳 ：&quot;timestamp&quot;: &quot;1709986011923&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#13位的毫秒数，时间戳(精确到毫秒)，当前时间5分钟内请求有效<br/>实现：<br/> cat sendmsg_2.php<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
function generate_timestamp_milliseconds() &#123;
&nbsp;&nbsp;&nbsp;&nbsp;$timestamp = microtime(true); // 获取当前Unix时间戳，包括微秒
&nbsp;&nbsp;&nbsp;&nbsp;echo $timestamp.&quot;&#92;n&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;$milliseconds = round($timestamp * 1000); // 转换为毫秒
&nbsp;&nbsp;&nbsp;&nbsp;return $milliseconds;
&#125;
echo generate_timestamp_milliseconds();


</textarea><br/>php sendmsg_2.php <br/>1709986816.8926&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #获取当前Unix时间戳，包括微秒&nbsp;&nbsp;<br/>1709986816893&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#转换为毫秒<br/><br/>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]php的round函数实现将微秒转换为毫秒]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>