@jsh/system

@jsh/system

Since v8.0.52

now()

Get the process id of the current process.

Syntax
now()
Parameters

None.

Return value

Current time in native object.

Usage example
1
2
const m = require("@jsh/system")
console.log("now =", m.now())

parseTime()

Syntax
parseTime(epoch, epoch_format)
parseTime(datetime, format)
parseTime(datetime, format, location)
Parameters
  • epoch Number
  • epoch_format String “s”, “ms”, “us”, “ns”
  • datetime String
  • format String
  • location Location timezone, default is ‘Local’ if omitted., e.g. system.location(‘EST’), system.location(‘America/New_York’)
Return value

Time in native object

Usage example
1
2
3
4
5
6
7
8
9
const {println} = require("@jsh/process");
const system = require("@jsh/system");
ts = system.parseTime(
    "2023-10-01 12:00:00",
    "2006-01-02 15:04:05",
    system.location("UTC"));
println(ts.In(system.location("UTC")).Format("2006-01-02 15:04:05"));

// 2023-10-01 12:00:00

location()

Syntax
location(timezone)
Parameters
  • timezone String time zone, e.g. "UTC", "Local", "GMT", "ETS", "America/New_York"
Return value

Location in native object

Usage example
1
2
3
4
5
6
const {println} = require("@jsh/process");
const system = require("@jsh/system");
ts = system.time(1).In(system.location("UTC"));
println(ts.Format("2006-01-02 15:04:05"));

// 1970-01-01 00:00:01
Last updated on