Page 1 of 1

nuFormatDateByString

Posted: Thu Aug 30, 2018 1:22 pm
by Timo
I'm trying to set a Default date using the format that has been set in the Format Builder. I came across this: https://forums.nubuilder.cloud/viewtopic. ... dar#p13786
var d = $("#the_date").attr('data-nuformat');
var f = nuFormats[d].format

$("#the_date").val(nuFormatDateByString(new Date(), f));
Obviously, the code was targeted for nuBuilder Pro. nuFormatDateByString() is not defined in v4. Is there a similar function to format a date?

Re: nuFormatDateByString

Posted: Tue Sep 04, 2018 4:03 am
by admin
Timo,

You could try this...

Code: Select all



function format_the_date(){
    
    var f = $('#the_date').attr('data-nu-format')           //-- "D|dd-mmm-yyyy"  
    var d = new Date();
    var s = d.getFullYear() + '-' + nuPad2(d.getMonth() + 1) + '-' + nuPad2(d.getDate());
    var f = nuFORM.addFormatting(s, f);
    
    return f;

}


Steven

Re: nuFormatDateByString

Posted: Sat Sep 08, 2018 8:22 am
by Timo
Steven, this works just fine. Thanks a thousand times!

Re: nuFormatDateByString

Posted: Sun Sep 09, 2018 12:08 am
by admin
.