JAVASCRIPT
Date utility functions
All samples are using Ink.requireModules
, please read how to use it at Ink.requireModules section
Function name | Description |
---|---|
.get(format, [_date]) | Formats a date object. |
.set([format], str_date) | Creates a date object based on a format string. |
Formats a date object.
This works exactly as php date() function. https://php.net/manual/en/function.date.php
format
The format in which the date it will be formatted._date
The date to format. Can receive unix timestamp or a date object. Defaults to current time.Code
Ink.requireModules(['Ink.Util.Date_1'], function(InkDate) {
var date1 = InkDate.get('Y-m-d H:i:s'); // current date
Ink.log(date1);
// 2014-04-07 03:31:34
// 1763830863 - is the Unix timestamp for 2025-11-22 17:01:03
var date2 = InkDate.get('Y-m-d H:i:s', 1763830863);
Ink.log(date2);
// 2025-11-22 17:01:03
});
Creates a date object based on a format string.
This works exactly as php date() function. https://php.net/manual/en/function.date.php
format
The format in which the date will be formatted. Defaults to 'Y-m-d'str_date
The date formatted.Code
Ink.requireModules(['Ink.Util.Date_1'], function(InkDate) {
var date1 = InkDate.set('Y-m-d H:i:s', '2025-11-22 17:01:03');
Ink.log(date1);
// Date {Sat Nov 22 2025 17:01:03 GMT+0000 (WET)}
var date2 = InkDate.set('Y-m-d', '2014-05-19');
Ink.log(date2);
// Date {Mon May 19 2014 00:00:00 GMT+0100 (WEST)}
});