2015年10月29日 星期四

[PHP] 日期,時間計算-DateTime篇

[PHP] 日期,時間計算-DateTime篇

現在時間

$date = new DateTime();

輸出格式轉換

$date = new DateTime('2015-10-30 14:00:00');
時間格式為2015-10-30 14:00:00

echo $date->format('Y/m/d H:i:s');
根據Y/m/d H:i:s設定會輸出2015/10/30 14:00:00

日期變更與計算

$date = new DateTime('+7 days');
echo $date->format('Y-m-d H:i:s'); //現在時間+七天

$date = new DateTime('+7 days');
echo #date->format('Y-m-d H:i:s'); //現在時間-七天

$date = new DateTime('2015-10-01 12:00:00')
$date->modify('+7 days'));
echo  $date->format('Y-m-d H:i:s'); //2015-10-08 12:00:00


日期比較

$date1 = new DateTime('2015-10-01');
$date2 = new DateTime('2015-10-02');
var_dump($date1 < $date2); //true
var_dump($date1 > $date2); //false
var_dump($date1 == $date2); //false

$dateInterval = date1->diff($date2);
參考: [php.net] class.dateinterval
echo dateInterval->d; // output: 1

2015年10月27日 星期二

[Android] Toast使用筆記

[Android] Toast使用筆記


如何判斷Toast是否正在顯示。

可使用toast.getView().getWindowVisibility()來判斷。


if (toast == null || toast.getView().getWindowVisibility() == View.Visibility) {
 //Toast正在顯示
     ...
}

其他待續...

2015年10月25日 星期日

[git] remote操作筆記

[git] remote操作

remote repository clone(複製)

git remote clone <git url>

remote repository add(追加)

git remote add <name> <git url>
        name: 自己命名 


remote repository 列表顯示

git remote -v

變更在local repository中登錄的remote repository位址

git remote set-url <name> <git url>
       name: 已設定的名字 

變更在local repository中登錄的remote repository名稱

git remote rename <old name> <new name>

在local repository指定製作remote repository的某個branch

git branch <branchname> origin/<branch>
        or     git checkout <branch>
       

向remote repository提交local repository的變更內容

git push <repository> <branch>
        repository: 命名的repository名稱或是位址。省略的話,以追蹤的remote repository為對象
        branch: branch名稱。省略的話,以local, remote都存在的branch為反映對象

確認remote repository的變更內容

git fetch <repository> <branch>
        repository: 命名的repository名稱或是位址。省略的話,以追蹤的remote repository為對象
        branch: branch名稱。省略的話,全部branch為對象

向local repository反映(更新)remote repository的變更內容

git pull <repository> <branch>
        repository: 命名的repository名稱或是位址。省略的話,以追蹤的remote repository為對象
        branch: branch名稱。省略的話,全部branch為對象

刪除remote repository的某個branch

git push --delete <repository> <branch>

2015年10月23日 星期五

[Android] SlidingMenu使用筆記

[Android] SlidingMenu使用筆記

說明:

Sliding Menu在手機的應用程式中是相當常見的設計,除了以前提到的
Navigation Drawer作法之外,還可以使用本文所提的Sliding Menu(jfeinstein10)的第三方資源來達成。
該資源提供豐富設定供開發者來使用,甚至有左右兩方的選單可以設定。

成果:

2015年10月14日 星期三

[Google App Script] 如何用Google App Script製作簡易Web API

[Google App Script] 如何用Google App Script製作簡易Web API - GET API 

你可以學到:

★Google App Script(簡稱GAS)的使用。
★簡單Get Web API的製作方式與發佈。

2015年10月7日 星期三