Last active
June 10, 2022 16:17
-
-
Save VenkataA/9a0b678666cad22b2615f6a6d5c6dc0e to your computer and use it in GitHub Desktop.
JavaScript Function - Check to see if date string is less than tomorrow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assumes a date string yyyy-mm-dd or mm/dd/yyyy | |
function isGreaterThanToday(inpDateField) { | |
var inpDate = inpDateField.rawValue; | |
var todaysDate = new Date(); | |
todaysDate.setHours(0,0,0,0); | |
var splitDate = inpDate.split('-'); | |
var nYear = splitDate[0]; | |
var nMonth = splitDate[1]; | |
var nDay = splitDate[2]; | |
if (splitDate.length < 3) { | |
splitDate = inpDate.split('/'); | |
nYear = splitDate[2]; | |
nMonth = splitDate[0]; | |
nDay = splitDate[1]; | |
} | |
console.println("month = " + nMonth + " day = " + nDay + " Year = " + nYear); | |
var enteredDateStr = nYear+"-"+nMonth+"-"+nDay; | |
var enteredDate = new Date(enteredDateStr ); | |
//Store tomorrow values | |
var tomorrowYear = todaysDate.getFullYear(); | |
var tomorrowMonth = todaysDate.getMonth() + 1; // 0 based | |
var tomorrowDay = todaysDate.getDate(); | |
console.println("tomorrow --- " + " Month = " + tomorrowMonth + " tomorrowDay = " + tomorrowDay + " tomorrowYear = " + tomorrowYear ); | |
if (enteredDate.getTime() > todaysDate.getTime()) return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment