Zig
Zig
DateTime - Get as Unix Time String
Demonstrates the GetAsUnixTimeStr method.Note: This example is only valid in Chilkat v9.5.0.65 or later.
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const date_time = try chilkat.DateTime.init();
defer date_time.deinit();
date_time.setFromCurrentSystemTime() catch {};
// (in seconds since the epoch: 00:00:00 UTC on 1 January 1970)
const b_local = true;
std.debug.print("Unix time: {s}\n", .{try date_time.getAsUnixTimeStr(alloc, b_local)});
// Sample output for test run on 2-Dec-2016:
// Unix time: 1480661608
}