Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

nuFormatDateByString

Questions related to using nuBuilder Forte.
Post Reply
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

nuFormatDateByString

Unread post 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?
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: nuFormatDateByString

Unread post 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
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Re: nuFormatDateByString

Unread post by Timo »

Steven, this works just fine. Thanks a thousand times!
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: nuFormatDateByString

Unread post by admin »

.
Post Reply