How to convert a Tessitura timestamp to a PHP Unix timestamp

Former Member
Former Member $organization

In PHP, it's common to work with specific dates/times using standard Unix timestamps (seconds since the Unix Epoch, January 1, 1970 at 00:00:00 GMT). Here's a handy function to convert a time returned by the Tessitura web API to a proper Unix timestamp:


    protected function convertTimeFromTessitura($tessTimestamp)
    {
        $hour   = substr($tessTimestamp,11,2);
        $minute = substr($tessTimestamp,14,2);
        $second = substr($tessTimestamp,17,2);
        $month  = substr($tessTimestamp,5,2);
        $date   = substr($tessTimestamp,8,2);
        $year   = substr($tessTimestamp,0,4);

        $timestamp = mktime($hour, $minute, $second, $month, $date, $year);
        return $timestamp;
    }