LocalTime (NotesDateTime - JavaScript)

Read-Write. A string representing a date-time in the local time zone.

Defined in

NotesDateTime

Syntax

getLocalTime() : string

setLocalTime(dt:string) : void

setLocalTime(hour:int, minute:int, second:int, hundredth:int) : void

setLocalTime(dt:Date) : void

setLocalDate(year:int, month:int, day:int) : void

setLocalDate(year:int, month:int, day:int, preserveLocalTime:boolean) : void

Usage

You must force the numeric parameters to int, for example, with parseInt.

Setting this property changes the value of the date-time that the object represents, and therefore affects the GMTTime property.

The dt, year, month, day, hour, minute, second, and hundredth parameters specify the new time. The preserveLocalTime parameter affects adjustments from the existing date that cross a daylight-saving time boundary. Specify true to increment or decrement the GMT time by one hour so that a 24-hour adjustment yields the same local time in the new day. If this parameter is false or omitted, GMT time remains as adjusted and local time gains or loses an hour.

Setting this property with a Date object may also change the time zone.

Examples

This computed field displays the creation date and time of the current database.
var dt:NotesDateTime = database.getCreated();
return "This database was created on " + dt.getLocalTime();
This onclick event for an input box (bound to requestScope.date) sets a date-time value based on user input. A correct date depends on valid user input.
// Create valid NotesDateTime object
var dt:NotesDateTime = session.createDateTime("Today 12");
// requestScope variables are bound to numeric input boxes
// must convert numeric user input to int
var year = parseInt(requestScope.year, 10);
var month = parseInt(requestScope.month, 10);
var day = parseInt(requestScope.day, 10);
var hour = parseInt(requestScope.hour, 10);
var minute = parseInt(requestScope.minute, 10);
var second = parseInt(requestScope.second, 10);
var hundredth = parseInt(requestScope.hundredth, 10);
// Set date and time from user input
try {
	dt.setLocalDate(year, month, day, true);
} catch(e) {
	requestScope.date = "Illegal specification for date";
	return;
}
try {
	dt.setLocalTime(hour, minute, second, hundredth);
} catch(e) {
	requestScope.date = "Illegal specification for time";
	return;
}
// Post local time to input box
requestScope.date = dt.getLocalTime();
This onclick event for an input box (bound to requestScope.date) sets a date-time value based on user input. A correct date depends on a valid user input string.
// Create valid NotesDateTime object
var dt:NotesDateTime = session.createDateTime("Today 12");
// Get date from user and set
dt.setLocalTime(requestScope.dt);
// Display date-time
requestScope.date = dt.getLocalTime();
This onclick event for an input box (bound to requestScope.date) sets a date-time value based on user input. A correct date depends on valid user input.
// Create valid NotesDateTime object
var dt:NotesDateTime = session.createDateTime("Today 12");
// Create Date object (note: January = 0 for Date)
// requestScope variables are bound to numeric input boxes
var date:Date = new Date(requestScope.year, (requestScope.month) - 1, requestScope.day,
requestScope.hour, requestScope.minute, requestScope.second, requestScope.hundredth);
// Set time
dt.setLocalTime(date);
// Post local time
requestScope.date = dt.getLocalTime();