numberAsPOSIXct: Convert a Numeric Time to a POSIXct Time

Description Usage Arguments Details Value Author(s) References See Also Examples


There are many varieties, according to the value of type as defined in ‘Details’.


numberAsPOSIXct(t, type = c("unix", "matlab", "gps", "argo", "ncep1", "ncep2",
  "sas", "spss", "yearday"), tz = "UTC")



an integer corresponding to a time, in a way that depends on type.


the type of time (see “Details”).


a string indicating the time zone, used only for unix and matlab times, since GPS times are always referenced to the UTC timezone.


  • "unix" employs Unix times, measured in seconds since the start of the year 1970.

  • "matlab" employs Matlab times, measured in days since what MathWorks [1] calls “January 0, 0000” (i.e. ISOdatetime(0, 1, 1, 0, 0, 0) in R notation).

  • "gps" employs the GPS convention. For this, t is a two-column matrix, with the first column being the the GPS "week" (referenced to 1999-08-22) and the second being the GPS "second" (i.e. the second within the week).

  • "argo" employs Argo times, measured in days since the start of the year 1900.

  • "ncep1" employs NCEP times, measured in hours since the start of the year 1800.

  • "ncep2" employs NCEP times, measured in days since the start of the year 1. (Note that, for reasons that are unknown at this time, a simple R expression of this definition is out by two days compared with the UDUNITS library, which is used by NCEP. Therefore, a two-day offset is applied. See [2,3].)

  • "sas" employs SAS times, indicated by type="sas", have origin at the start of 1960.

  • "spss" employs SPSS times, in seconds after 1582-10-14.

  • "yearday" employs a convention in which t is a two-column matrix, with the first column being the year, and the second the yearday (starting at 1 for the first second of January 1, to match the convention used by Sea-Bird CTD software).


A POSIXct time vector.


Dan Kelley


[1] Matlab times:

[2] NCEP times:

[3] problem with NCEP times:

See Also


Other things related to time: ctimeToSeconds, julianCenturyAnomaly, julianDay, numberAsHMS,, secondsToCtime, unabbreviateYear


numberAsPOSIXct(0)                     # unix time 0
numberAsPOSIXct(1, type="matlab")      # matlab time 1
numberAsPOSIXct(cbind(566,345615), type="gps") # Canada Day
numberAsPOSIXct(cbind(2013, 0), type="yearday") # start of 2013

Search within the oce package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.