Expand my Community achievements bar.

SOLVED

Get CURRENT time and Date?

Avatar

Level 8

Hello

How to get CURRENT time and CURRENT date? I need this because, am creating a TEXT (multi line) field, when in user enters his/her COMMENTS/some notes/remarks, so i need to take care this COMMENTS by concatenating the TIME STAMP

For example, I opened my_form at 14:10, i got a tele call, its about 15 min., then i am back(now the time is 14:25) to my_form and entered some comments, so, i need to store these comments together with the TIME STAMP, meaning its 14:25 (not, 14:10)

Pls. let me kmow in Java Script

Thank you

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Here is one method.

Date

// form1.page1.subform1.date_::ready:layout - (FormCalc, client)

$.rawValue = Concat(Num2Date(Date(), "MM/DD/YYYY"))

Time

// form1.page1.subform1.time_::initialize - (JavaScript, client)

var date = new Date();

var hours = date.getHours();

if (hours > 12) {

    this.rawValue = (hours - 12) + ":" + date.getMinutes() + " PM";

}

else {

    this.rawValue = hours + ":" + date.getMinutes() + " AM";

}

Steve

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

Here is one method.

Date

// form1.page1.subform1.date_::ready:layout - (FormCalc, client)

$.rawValue = Concat(Num2Date(Date(), "MM/DD/YYYY"))

Time

// form1.page1.subform1.time_::initialize - (JavaScript, client)

var date = new Date();

var hours = date.getHours();

if (hours > 12) {

    this.rawValue = (hours - 12) + ":" + date.getMinutes() + " PM";

}

else {

    this.rawValue = hours + ":" + date.getMinutes() + " AM";

}

Steve

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----