Last active
April 21, 2021 15:10
-
-
Save W3BGUY/3dfc0141be3f1cd89c7175738f9de6ad to your computer and use it in GitHub Desktop.
NetSuite - Convert Date Object into NetSuite usable Date Format
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
// function to add leading zeros on date parts. | |
function zeroPad(num,len){ | |
var str=num.toString(); | |
while(str.length<len){str='0'+str;} | |
return str; | |
} | |
// function to format date object into NetSuite's mm/dd/yyyy format. | |
function formatNSDate(dateObj){ | |
if(dateObj){ | |
var nsFormatDate=zeroPad(dateObj.getMonth()+1,2)+'/'+zeroPad(dateObj.getDate(),2)+'/'+dateObj.getFullYear(); | |
return nsFormatDate; | |
} | |
return null; | |
} | |
// example usage | |
var thisDate=formatNSDate(new Date()); |
Ahh, I see what you are referring to. addZeros was an intermediary function, that I removed. Good catch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function zeroPad(num,len){
should be
function addZeros(num,len){
right?