简体   繁体   中英

'ts' Number Field in Database? (ex. 1428881039)

Thanks to outsourced development, each row in many of my tables has an undocumented field called ts with values such as 1428881039 . This is in addition to an actual created_at timestamp field with values such as 2015-04-12 17:23:59 MDT .

These values are passed to this function before displaying it on the web page:

public static function display($ts, $created_at, $format = self::FORMAT_DETAILS){
    if ($ts && Session::has('tz_offset')){
        $adminTzOffset = Session::get('tz_offset');
        $final = (int)$ts - (int)$adminTzOffset;
        return date($format, $final);
    }else{
        return $created_at;
    }
}

I understand that it has something to do with possibly making sure that the date shown is for the user's correct timezone, but it doesn't even seem to work; it ends up showing the wrong time. Obviously I could just display the created_at timestamp, but I understand what this is trying to do here.

Any ideas of what this ts field represents?

Based on the info garnered from the comments, I would say that the ts field is an attempt to record UTC time - since it appears it is 6 hours ahead of your created_at field.

The code itself looks like it is using this $ts value to calculate a corrected timezone based off a session variable. If you're getting incorrect times, maybe the logged in user has an incorrect timezone setup?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM