Server Management
Unixタイムスタンプをファイルメーカーのタイムスタンプに変換する 11/12/2008 20:55:00
Unixのタイムスタンプは1970年1月1日0時0分0秒から、一方ファイルメーカーのタイムスタンプは0001年1月1日0時0分0秒からの秒数になっている。(世界標準時)

そのため、Unixのタイムスタンプフィールド名がtsとして、ファイルメーカーに取り込んだときの変換(日本時間+9時間を反映)の計算式は、

ts + Timestamp ( Date ( 1 ; 1 ; 1970 ) ; Time ( 0 ; 0 ; 0 ) ) + 60*60*9

となる。タイムスタンプは単純に経過秒数なので、そのまま秒を足せば自動で変換してくれる。

逆に、ファイルメーカーのタイムスタンプや日付データを整形してWebに表示させるPHPは、

date("Y/m/d", strtotime($searchData['日付・タイムスタンプフィールド'][0]))
date("Y/m/d", mktime($searchData['日付・タイムスタンプフィールド'][0]))

のように、一度UNIXタイムスタンプに変換したデータを日付フォーマットに変換する。




Comments

Add comment for this article
Comment
URL
Password (You can revise your comment later with this password.)
Security Code
Input this text in the right textarea.
 



03enterprise

Copyright © Majestic, Inc. Privacy Policy