网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站设计 > PHP
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 58.241.198.160
Old 2013-05-09, 12:01 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default how to generate random time, pls?

Q:
say i need random time between 01-01-1970 to 12-31-2012,
how to do, pls?

A:
$timestamp1 = strtotime('01-01-1970');
$timestamp2 = strtotime('31-12-2012');
echo "timestamp 1 (01-01-1970) : ".$timestamp1."<br />timestamp 2 (31-12-2012) : ".$timestamp2;

$rand_timestamp = rand(-3600, 1356908400);
$rand_date = date('d-m-Y', $rand_timestamp);
echo "<br />random date between 01-01-1970 and 31-12-2012 : ".$rand_date;

$now_timestamp = time();
$rand_timestamp_till_now = rand(-3600, $now_timestamp);
$rand_date_till_now = date('d-m-Y', $rand_timestamp_till_now);
echo "<br />random date between 01-01-1970 and NOW : ".$rand_date_till_now;

-----------------------

A:

<?php

$timestamp = strtotime('2012-12-31');

// unix timestamp for 1970-01-01 is => 0

$result = rand(0, $timestamp);

print date('Y/m/d h:i:s', $result);

?>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
国外主机是否有CPU Time的限制吗? car 虚拟主机 0 2008-04-11 06:33 PM
Top 12 Free Link Building Tips That Will Boost Your Traffic In No Time yahoo 网站链接开发 0 2007-08-17 11:02 AM
Secret Out - How Google Ranks Websites smiling 搜索引擎市场营销研究 0 2006-05-14 06:51 PM
999句最常用英语口语 sunshine 商务外语 2 2006-03-16 07:15 PM
AdSense Referral Program: Time Limit Raised to 180 Days smiling Google Adsense 0 2006-03-04 06:47 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:41 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.