Wiki Diff updating oE to_unix, revision #1 to tip


@[:datetime:to_unix|]
==== to_unix
<eucode>
include datetime.e -- (default namespace is datetime)
include datetime.e
namespace datetime
public function to_unix(datetime dt)
</eucode>

Converts a datetime value to the //Unix// numeric format (seconds since ##EPOCH_1970##).
converts a datetime value to the //Unix// numeric format (seconds since ##EPOCH_1970##).

===== Parameters:
# ##dt## : a datetime to be queried.

===== Returns:
An **atom**, so this will not overflow during the winter 2038-2039.


===== Example 1:
<eucode>
include std/datetime.e

atom secs_since_epoch = to_unix(now())
secs_since_epoch = to_unix(now())
-- secs_since_epoch is equal to the current seconds since epoch
? secs_since_epoch
</eucode>

===== Result:

1567910956 (your number will vary!)


===== See Also:
[[:from_unix]], [[:format]]

Search



Quick Links

User menu

Not signed in.

Misc Menu