- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 10:53 AM - edited ā11-03-2023 11:53 AM
Can anyone explain how to use datetime in from this 2023-11-03 22:51:34 to this 20231103-225134.formate on onchange client script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 01:48 PM
Hello @Ajay Singh2
It seems you have already brought the datetime
Just use the below code :-
var gdt = g_user_date_time_format;
var dateTime = gdt.split(' ');
var date=dateTime[0].split('-');
var time=dateTime[1].split(':');
var res1= date[0]+date[1]+date[2];
var res2= time[0]+time[1]+time[2];
var res=res1 +'-' +res2;
alert(res);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 02:34 PM
@Ajay Singh2Nah, if you would be using my code, you would have the date formatted as desired in there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 12:34 PM
Where is 2023-11-03 22:51:34 coming from?
I mean running
var dateIn = getDateFromFormat('2023-11-03 22:51:34', 'yyyy-MM-dd HH:mm:ss');
var dateOut = new Date(dateIn);
alert(formatDate(dateOut, 'yyyyMMdd-HHmmss'));
In the browser's console (or a Client Script) will get you an alert showing
20231103-225134
But I'm assuming you need a solution that accepts dynamic input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 12:39 PM
yes i need a dynamic solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 12:50 PM
Hello @Ajay Singh2
var gdt = g_form.getValue('datetimefieldname')
var dateTime = gdt.split(' ');
var date=dateTime[0].split('-');
var time=dateTime[1].split(':');
var res1= date[0]+date[1]+date[2];
var res2= time[0]+time[1]+time[2];
var res=res1 +'-' +res2;
gs.info(res);
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-03-2023 12:51 PM
So answer the question: where is 2023-11-03 22:51:34 coming from?