[……]
PHP 國曆轉西元日期
<?php
// 國曆轉西元日期
//echo ROC_years_to_date('70/8/8');
//echo ROC_years_to_date('71/8/8','Y/m/d');
function ROC_years_to_date($date,$format='Y-m-d')
{
$arr = array();
preg_match_all("/[0-9]+/", $date , $arr);
$y = intval($arr[0][0])+1911;
$m = intval($arr[0][1]);
$d = intval($arr[0][2]);
return date($format,strtotime($y.'/'.$m.'/'.$d));
}
?>
[……]
PHP 取年齡或年資 get age of date
取年齡或年資
/* 取年資 https://vector.cool date $date 到職日 ex:2006/3/8 date $date2 = null 離職日 ex:2017/5/14 return int 年資 */ function get_age($date,$date2=NULL){ $time = (empty($date2))?time():strtotime($date2); $time = $time - strtotime($date); return intval($time / (365*24*60*60)); }
用法:
這邊有個要注意的地方,使用這方法須先設定時區
date_default_timezone_set()
第二個參數不帶則為還在職,也就是取目前時間
date_default_timezone_set("Asia/Taipei"); echo get_age('2007/6/25'); echo get_age('2007/7/28','2017/12/23');
[……]
PHP 時間運算 取2日期間共幾年 get years between two dates
php get years between two dates
取2日期間共幾年
/* get years between two dates https://vector.cool date $date ex:2006/3/8 date $date2 ex:2017/5/14 return int */ function get_years_between_two_dates($date,$date2=NULL){ $time = (empty($date2))?time():strtotime($date2); $time = $time - strtotime($date); return intval($time / (365*24*60*60)); }
用法:
這邊有個要注意的地方,使用這方法須先設定時區
date_default_timezone_set()
date_default_timezone_set("Asia/Taipei"); echo get_years_between_two_dates('2007/7/28','2017/12/23');
[……]
MySQL 判斷兩個時間區間是否重疊 Determine Whether Two Date Ranges Overlap
判斷兩個時間區間是否重疊
<?php
/* 判斷兩個時間區間是否重疊 */
/* that it is sufficient to say that the two ranges overlap */
WHERE (StartDate1 <= EndDate2) AND (StartDate2 <= EndDate1)
?>
http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap[……]
jQuery slideLeft
$('.v_search_btn').click(function(e){
$('.v_search_form_div').animate({width:'toggle'},350);
});
<div class="v_search_form_div" style=" display:none;overflow:hidden">
[……]
Javascript 常用取網址 window.location
// ‘http://127.0.0.1/osac.com.tw/zh-tw/tag_page.php?aaa=1&bbb=2’
// 當前頁面的 URL
window.location.href
// output : ‘http://127.0.0.1/osac.com.tw/zh-tw/tag_page.php?aaa=1&bbb=2’
// 域名
window.location.hostname;
// output : ‘127.0.0.1’
//當前頁的路徑和文件名
window.location.pathname;
// output : ‘/osac.com.tw/zh-tw/tag_page.php’
//所使用的網絡協議(http://或https://)
console.log(‘location.protocol=’+window.location.protocol);
// output : ‘http:’
//取URL參數
urlParam = decodeURIComponent(location.search)
// output : ‘?aaa=1&bbb=2′[……]
Google Youtube iframe 無法重複播放的解決方案 Loop not working
在參數中加入playlist這個參數,若只有一個影片就填一個就好
<iframe class="embed-responsive-item"id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?&autoplay=1&loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3&playlist=M7lc1UVf-VE"
frameborder="0" allowfullscreen></iframe>
出處:http://stackoverflow.com/questions/25779966/youtube-iframe-loop-doesnt-work
[……]
Javascript for each in 做到跟PHP foreach 一樣的使用方式
PHP 二維陣列轉一維陣列
$test_arr = array(array(“aa”), array(“bb”), array(“cc”));
‘二維陣列<br/>’.print_r($test_arr).'<br/>’;
$new_arr = call_user_func_array(‘array_merge’, $test_arr);
‘一維陣列<br/>’.print_r($new_arr);[……]