Current UTC date, with no hours, minutes, seconds

Function

		/** 
		 * @description creates current utc date, with no hours, minutes, seconds
		 * @returns {object} date object
		 */
		createCurrentUTCDate: function() {
			var oDate = new Date();
			var iUTCDate = Date.UTC(oDate.getUTCFullYear(), oDate.getUTCMonth(),
				oDate.getUTCDate(), 0, 0, 0);

			return new Date(iUTCDate);
		}

Example

this.createCurrentUTCDate();
//Expected output: Tue Jun 27 2023 02:00:00 GMT+0200
new Date();
//Expected output: Tue Jun 27 2023 14:48:17 GMT+0200

Related Information

Leave a Reply

Your email address will not be published. Required fields are marked *