Get elapsed time using a datetime field, e.g 10 minutes ago


function getTimeElapsed(ndt1:NotesDateTime){

	var ndt2:NotesDateTime = session.createDateTime("Today");
	ndt2.setNow();
	var dt3:NotesDateTime = ndt2.timeDifference(ndt1);

	var min = parseInt(dt3/60,0);
	var hours = parseInt(min/60,0);
	var days = parseInt(hours/24,0);
	
	if(days>0 && days <1){
		return "1 day ago";
	}else if(days>0){
		return days + "days ago";
	}else if(hours>0 && hours<2){
		return "1 hour ago";
	}else if(hours>1){
		return hours + " hours ago";
	}else if(min>0){
		return min + " minutes ago";
	}else if(min==0){
		return "less than a minutes ago";
	}else{
		return "Error "
	}
}


All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...