posts - 82, comments - 269, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          常用PHP時間函數

          Posted on 2007-10-16 22:57 itspy 閱讀(299) 評論(0)  編輯  收藏

          /**formate datetime to timestamp**/
          function convert_datetime($str) {
           list($date, $time) = explode(' ', $str);
           list($year, $month, $day) = explode('-', $date);
           list($hour, $minute, $second) = explode(':', $time);
           $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
           return $timestamp;
          }

          /**formate timestamp to datetime **/
          function convert_timestamp ($timestamp)
          {
           return   strftime ("%Y-%m-%d %H:%M:%S", $timestamp); 
           
          }

          /**formate m/d/y to datetime, in order to store to DB**/

          function getDateTime($strtime){


           $array = explode("/",$strtime);

           $month = $array[0];
           $day = $array[1];
           $year = $array[2];

           #int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
           
           $timestamp =mktime(0,0,0,$month,$day,$year);
           
           return convert_timestamp($timestamp);
          }


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 涞源县| 望城县| 旬邑县| 吴堡县| 岳阳市| 临洮县| 白山市| 兖州市| 华池县| 江达县| 清河县| 金山区| 木兰县| 林口县| 门头沟区| 嘉荫县| 台北市| 垫江县| 繁昌县| 安图县| 尼勒克县| 青川县| 赣榆县| 会宁县| 栾川县| 正宁县| 五莲县| 绿春县| 宁河县| 明光市| 新邵县| 同心县| 互助| 浑源县| 牡丹江市| 平原县| 东明县| 宿迁市| 综艺| 宕昌县| 娄底市|