time api
2008年12月9日 星期二
2008年8月21日 星期四
time range conditions
Record.find(:all, :conditions => {:todo_time => Time.now.ago(10.days)..Time.now})
標籤:
conditions,
rails,
time
2008年7月17日 星期四
Time, 想把秒數直接弄成幾天幾分幾秒
#at 從1970年1月1日後 幾秒鐘的時間
#at 直接拿到的是local time, 還要用getgm換成gmtime 就可以了
>> Time.at(10000).getgm
=> Thu Jan 01 02:46:40 UTC 1970
>> Time.gm(2000)
=> Sat Jan 01 00:00:00 UTC 2000
>> Time.mktime(2000)
=> Sat Jan 01 00:00:00 +0800 2000
>> Time.mktime(2000).getgm
=> Fri Dec 31 16:00:00 UTC 1999
#at 直接拿到的是local time, 還要用getgm換成gmtime 就可以了
>> Time.at(10000).getgm
=> Thu Jan 01 02:46:40 UTC 1970
>> Time.gm(2000)
=> Sat Jan 01 00:00:00 UTC 2000
>> Time.mktime(2000)
=> Sat Jan 01 00:00:00 +0800 2000
>> Time.mktime(2000).getgm
=> Fri Dec 31 16:00:00 UTC 1999
2008年6月9日 星期一
2008年5月18日 星期日
time, setTimeout, setInterval, fadeOut, callback, 跑馬燈
- 自己用setTimeout 做interval 比較好, 爆掉一次就讓他爆掉, 別用setInterval錯了還一直跑,利用 setTimeout 自己call 自己
- fadeOut後, 才做替換html的hide動作, 需要將他放到callback 裡, 不然html hide和fadeOut是同步的這樣會直接看到消失而已
- 可以將跑馬燈需要的option 藏起來, 像這樣藏在hidden_forum裡, 用size()可以知道裡面包含幾個
<div id='hidden_forum' style='display:none'>
<div>abc</div>
<div>def</div>
</div>
<script type="text/javascript">
var index = 0;
var shuffler;
var news;
var max_news;
function replace_news(){
index = index % max_news
news = $('#hidden_forum div:eq('+index+')').clone();
shuffler.fadeOut('slow', function() {shuffler.html(news.html()).hide().fadeIn('slow') });
index++;
if(max_news > 1) { var dummy = setTimeout(replace_news, 5000); }
}
$(function(){
max_news = $('#hidden_forum div').size();
if(max_news > 0){
shuffler = $('div.news div');
replace_news();
}
});
</script>
標籤:
jquery,
setTimeout,
time
訂閱:
文章 (Atom)