SAS Timestamp Converter
Convert SAS datetime seconds or date days since
1960-01-01 UTC ↔ human-readable dates. Hex (0x…
) or decimal.
Fully client-side.
Related Tools
UNIX Timestamp Converter · Apple Cocoa/Core Foundation Time · LDAP / FILETIME Converter · Mac HFS+ Timestamp
Results always include UTC; this controls an additional local view.
1) SAS Value → Date
Use the Unit selector above to choose seconds vs days.
2) Date → SAS Value
Interpreted in your current local time zone.
If an offset is provided, it will be respected.
Outputs as SAS datetime (seconds).
About SAS Time
SAS datetime counts seconds (fractional allowed) since 1960-01-01T00:00:00Z. SAS date counts whole days since 1960-01-01.
- UNIX ↔ SAS datetime (seconds):
unix = sasSec − 315,619,200
;sasSec = unix + 315,619,200
- UNIX ↔ SAS date (days):
sasDays = floor(unix / 86,400) + 3,653
;unix ≈ (sasDays − 3,653) × 86,400
- Time zone & DST: Stored values are UTC-based; only display formatting changes with time zone/DST.
SAS Time: Code Snippets
Convert between SAS datetime seconds / date days and ISO-8601 dates.
JavaScript
const SAS_UNIX_OFFSET_SEC = 315_619_200; // 1960→1970
function unixToSasSeconds(unixSec){ return unixSec + SAS_UNIX_OFFSET_SEC; }
function sasSecondsToUnix(sasSec){ return sasSec - SAS_UNIX_OFFSET_SEC; }
function sasSecondsToDate(sasSec){ return new Date((sasSec - SAS_UNIX_OFFSET_SEC) * 1000); }
function dateToSasSeconds(d){ return d.getTime()/1000 + SAS_UNIX_OFFSET_SEC; }
function unixToSasDays(unixSec){ return Math.floor(unixSec/86400) + 3653; }
function sasDaysToUnix(sasDays){ return (sasDays - 3653) * 86400; }
Python
import datetime
SAS_UNIX_OFFSET_SEC = 315_619_200
def sas_seconds_to_datetime(s): return datetime.datetime.fromtimestamp(s - SAS_UNIX_OFFSET_SEC, tz=datetime.timezone.utc)
def datetime_to_sas_seconds(dt):
if dt.tzinfo is None: dt = dt.astimezone()
return dt.timestamp() + SAS_UNIX_OFFSET_SEC
def sas_days_to_date(d): # returns date at 00:00 UTC
sec = (d - 3653) * 86400
return datetime.datetime.fromtimestamp(sec, tz=datetime.timezone.utc)