Node.js Requires Chilkat v11.0.0+
Node.js
Read the sender’s Date in UTC and local time
See more Email Object Examples
Parse the Date header from an EML file, then print the same instant in UTC and the current computer’s local zone. Date is the time reported by the sender. For a relay timestamp, use a Received header.
Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
var email = new chilkat.Email();
success = email.LoadEml("message.eml");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
var dateHeader = email.GetHeaderField("Date");
var when = new chilkat.CkDateTime();
success = when.SetFromRfc822(dateHeader);
if (success !== true) {
console.log("Failed: when.SetFromRfc822.");
return;
}
console.log("Header: " + dateHeader);
console.log("UTC: " + when.GetAsTimestamp(false));
console.log("Local: " + when.GetAsTimestamp(true));
}
chilkatExample();