---
title: "UnixTime"
language: "en"
type: "Symbol"
summary: "UnixTime[] gives the total number of seconds since the beginning of January 1, 1970, in the GMT time zone. UnixTime[{y, m, d, h, m, s}] gives the Unix time specification corresponding to a date list. UnixTime[date] gives the Unix time specification corresponding to a DateObject. UnixTime[string] gives the Unix time specification corresponding to a date string. UnixTime[{ string, {SubscriptBox[e, 1], SubscriptBox[e, 2], ...}}] takes the date string to contain the elements SubscriptBox[e, i]."
keywords: 
- unixtime
- date
- time
- Unix
canonical_url: "https://reference.wolfram.com/language/ref/UnixTime.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "External Operations"
    link: "https://reference.wolfram.com/language/guide/ExternalOperations.en.md"
  - 
    title: "Date & Time"
    link: "https://reference.wolfram.com/language/guide/DateAndTime.en.md"
related_tutorials: 
  - 
    title: "Date and Time Functions"
    link: "https://reference.wolfram.com/language/tutorial/GlobalAspectsOfWolframSystemSessions.en.md#28650"
  - 
    title: "Global System Information"
    link: "https://reference.wolfram.com/language/tutorial/GlobalAspectsOfWolframSystemSessions.en.md#25706"
---
# UnixTime

UnixTime[] 
gives the total number of seconds since the beginning of January 1, 1970, in the GMT time zone.
	UnixTime[{y,m,d,h,m,s}]
gives the Unix time specification corresponding to a date list.
	UnixTime[date]
gives the Unix time specification corresponding to a DateObject.
	UnixTime["string"]
gives the Unix time specification corresponding to a date string.
	UnixTime[{"string",{"Subscript[e, 1]","Subscript[e, 2]",\[Ellipsis]}}]
takes the date string to contain the elements "Subscript[e, i]".

## Details

* ``UnixTime[]`` returns the number of seconds that have elapsed since {1970, 1, 1, 0, 0, 0.} Greenwich Mean Time (GMT), not counting leap seconds.

* ``UnixTime[time]`` assumes that the given ``time`` is in ``\$TimeZone``, unless it is a ``DateObject`` or ``TimeObject`` with an explicit ``TimeZone`` option value.

* ``UnixTime[]`` returns the nearest whole second, down to a granularity of ``\$TimeUnit`` seconds.

* Shorter lists can be used in ``UnixTime[{y, m, …}]``: ``{y}`` is equivalent to ``{y, 1, 1, 0, 0, 0}``, ``{y, m}`` to ``{y, m, 1, 0, 0, 0}``, etc.

* Values of ``m``, ``d``, ``h``, ``m``, ``s`` outside their normal ranges are appropriately reduced. Noninteger values of ``d``, ``h``, ``m``, ``s`` can also be used.

## Examples (11)

### Basic Examples (3)

Unix time in seconds since January 1, 1970:

```wl
In[1]:= UnixTime[]

Out[1]= 1423155963
```

---

Convert from a date object to Unix time:

```wl
In[1]:= UnixTime[DateObject[{2014, 12, 18, 10}, "Hour", "Gregorian", -4.]]

Out[1]= 1418911200

In[2]:= UnixTime[DateObject[{2007, 1, 1, 0, 0, 0.}, "Instant", "Gregorian", 0.]]

Out[2]= 1167609600
```

---

Convert from a date string to Unix time:

```wl
In[1]:= DateString[]

Out[1]= "Tue 26 May 2015 18:07:21"

In[2]:= UnixTime[%]

Out[2]= 1432678041
```

### Scope (6)

Inputs are assumed to be in ``\$TimeZone``. ``Block`` can be used to specify a different input time zone:

```wl
In[1]:= $TimeZone

Out[1]= -4.

In[2]:= UnixTime["2006-12-1"]

Out[2]= 1164945600

In[3]:= Block[{$TimeZone = 0}, UnixTime["2006-12-1"]]

Out[3]= 1164931200
```

---

``DateObject`` expressions can include their own ``TimeZone`` specification:

```wl
In[1]:= UnixTime[DateObject[{2015, 2, 19, 11, 0, 0}, TimeZone -> 0]]

Out[1]= 1424343600

In[2]:= UnixTime[DateObject[{2015, 2, 19, 11, 0, 0}, TimeZone -> -5]]

Out[2]= 1424361600
```

---

Separators are assumed if not specified:

```wl
In[1]:= Block[{$TimeZone = -5}, UnixTime[{"2/23/2007", {"Month", "Day", "Year"}}]]

Out[1]= 1172206800
```

Give explicit separators:

```wl
In[2]:= Block[{$TimeZone = -5}, UnixTime[{"2/23/2007", {"Month", "/", "Day", "/", "Year"}}]]

Out[2]= 1172206800
```

---

Date lists are converted to standard normalized form:

```wl
In[1]:= Block[{$TimeZone = 2}, UnixTime[{2006, 2, 31}]]

Out[1]= 1141336800

In[2]:= Block[{$TimeZone = 2}, UnixTime[{2006, 3, 3}]]

Out[2]= 1141336800
```

---

Day, hour, minute, and second values in input date lists can be noninteger:

```wl
In[1]:= Block[{$TimeZone = -7}, UnixTime[{2007, 3, 15.5}]]

Out[1]= 1173985200

In[2]:= Block[{$TimeZone = -7}, UnixTime[{2007, 3, 15, 12.3}]]

Out[2]= 1173986280
```

---

The current year is used if not specified in a string:

```wl
In[1]:= Block[{$TimeZone = 4}, UnixTime[{"2/15", {"Month", "Day"}}]]

Out[1]= 1423944000
```

### Properties & Relations (2)

``UnixTime`` converts a date specification into Unix time form:

```wl
In[1]:= UnixTime[Now]

Out[1]= 1484764416
```

``FromUnixTime`` converts back into a ``DateObject`` expression:

```wl
In[2]:= FromUnixTime[%]

Out[2]= DateObject[{2017, 1, 18, 12, 33, 36.}, "Instant", "Gregorian", -6.]
```

---

Compute the number of seconds between January 1, 1900, and January 1, 1970:

```wl
In[1]:= Block[{$TimeZone = 0}, Abs[UnixTime[{1900, 1, 1, 0, 0, 0}]]]

Out[1]= 2208988800
```

## See Also

* [`FromUnixTime`](https://reference.wolfram.com/language/ref/FromUnixTime.en.md)
* [`AbsoluteTime`](https://reference.wolfram.com/language/ref/AbsoluteTime.en.md)
* [`DateList`](https://reference.wolfram.com/language/ref/DateList.en.md)
* [`DateString`](https://reference.wolfram.com/language/ref/DateString.en.md)
* [`DateObject`](https://reference.wolfram.com/language/ref/DateObject.en.md)
* [`JulianDate`](https://reference.wolfram.com/language/ref/JulianDate.en.md)
* [`FromJulianDate`](https://reference.wolfram.com/language/ref/FromJulianDate.en.md)
* [`DateValue`](https://reference.wolfram.com/language/ref/DateValue.en.md)
* [`Now`](https://reference.wolfram.com/language/ref/Now.en.md)
* [`SessionTime`](https://reference.wolfram.com/language/ref/SessionTime.en.md)
* [`TimeUsed`](https://reference.wolfram.com/language/ref/TimeUsed.en.md)
* [`Clock`](https://reference.wolfram.com/language/ref/Clock.en.md)
* [`AbsoluteTiming`](https://reference.wolfram.com/language/ref/AbsoluteTiming.en.md)
* [`Timing`](https://reference.wolfram.com/language/ref/Timing.en.md)
* [`\$TimeZone`](https://reference.wolfram.com/language/ref/$TimeZone.en.md)
* [`\$TimeUnit`](https://reference.wolfram.com/language/ref/$TimeUnit.en.md)
* [`FileDate`](https://reference.wolfram.com/language/ref/FileDate.en.md)
* [`UnixTime`](https://reference.wolfram.com/language/ref/interpreter/UnixTime.en.md)
* [`Time`](https://reference.wolfram.com/language/ref/interpreter/Time.en.md)

## Tech Notes

* [Date and Time Functions](https://reference.wolfram.com/language/tutorial/GlobalAspectsOfWolframSystemSessions.en.md#28650)
* [Global System Information](https://reference.wolfram.com/language/tutorial/GlobalAspectsOfWolframSystemSessions.en.md#25706)

## Related Guides

* [External Operations](https://reference.wolfram.com/language/guide/ExternalOperations.en.md)
* [Date & Time](https://reference.wolfram.com/language/guide/DateAndTime.en.md)

## History

* [Introduced in 2015 (10.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn101.en.md)