Skip to content

Instantly share code, notes, and snippets.

@marwan-nwh
Created May 23, 2022 10:41
Show Gist options
  • Save marwan-nwh/53ce25a13a99c716d32dc4ee06a1bbf4 to your computer and use it in GitHub Desktop.
Save marwan-nwh/53ce25a13a99c716d32dc4ee06a1bbf4 to your computer and use it in GitHub Desktop.
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(["N/format"], function (format) {
function formatDate(date) {
var formatedDate = format.format({
value: new Date(date),
type: format.Type.DATE,
});
return formatedDate.toString();
}
function formatDate2(date) {
return format
.format({
value: new Date(date),
type: format.Type.DATETIME,
})
.toString()
.split(" ")[0];
}
function execute() {
try {
log.audit("formatDate", formatDate("2022-05-18T04:57:06.798Z"));
log.audit("formatDate2", formatDate2("2022-05-18T04:57:06.798Z"));
} catch (err) {
log.audit("Error", err);
}
}
return {
execute: execute,
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment