Ads 468x60px

##EasyReadMore##

14 4月, 2017

JX9 datetime 轉 timestamp 的做法 ,使用 strtok,mktime

範例如下:


"        $start_tm = \"2017-02-09 06:14:30\";"\
"        $del_str = \" \";"\
"        $date = strtok($start_tm,$del_str);"\
"        $time = strtok($del_str);"\
"         print \"conditon date: \",$date,\" time:\",$time..JX9_EOL;"\
"        $del_str = \"-\";"\
"        $year = strtok($date,$del_str);"\
"        $month = strtok($del_str);"\
"        $day = strtok($del_str);"\
"         print \"year: \",$year,\" month:\",$month,\" day:\",$day..JX9_EOL;"\
"        $del_str = \":\";"\
"        $hour = strtok($time,$del_str);"\
"        $minute = strtok($del_str);"\
"        $second = strtok($del_str);"\
"         print \"hour: \",$hour,\" minute:\",$minute,\" second:\",$second..JX9_EOL;"\
"        $timestamp = mktime($hour,$minute,$second,$month,$day,$year);"\
"         print \"timestamp:\",$timestamp..JX9_EOL;"\

最後得到的結果


timestamp:1489011270

0 意見:

張貼留言

 
Blogger Templates