Sample code for 30+ languages & platforms
Zig

Get Current Date/Time as Timestamp (YYYY-MM-DDThh:mm:ssTZD)

Demonstrates how to get the current system date/time in YYYY-MM-DDThh:mm:ssTZD format.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    const dt = try chilkat.DateTime.init();
    defer dt.deinit();

    try dt.setFromCurrentSystemTime();

    // Get a UTC time.
    var b_local: bool = false;
    var timestamp: [:0]const u8 = try dt.getAsTimestamp(alloc, b_local);
    std.debug.print("Current UTC Time: {s}\n", .{timestamp});

    // Get a local time.
    b_local = true;
    timestamp = try dt.getAsTimestamp(alloc, b_local);
    std.debug.print("Current Local Time: {s}\n", .{timestamp});

    // Sample output:
    //
    // Current UTC Time: 2022-03-01T00:48:58Z
    // Current Local Time: 2022-02-28T18:48:58-06:00
}