Hi,
I had a web form to let client to fill out from their device but one field is date and time. I'd like to get client's device date time auto fill not from the server. How can I do it?
Thanks!
Ben-J Chen wrote:
You can goto the Built-In Function- >Date and Time - > Here you will find multiple functions to get current Date & Time from Local Client.
For example: CurrDate() - It will return Device Date when it is called on Client Device, Server when on Server Platform respectively.
Incase you need the Auto filled, add the appropriate function as to the value of your respective textInput field, You can also use Format to get desired results.
Cheers,
Assif
Hi
Thanks but I am getting the date and time from server which I do not want it. Do I do any wrong?
assif_tiger wrote:
If you want to use server time than use from your Aggregate Directly, If you don't want than Directly use the BuiltInFunction there.
You can use the Builtin-Function Directly in Variable :
There is no Builtin-Function in the selection list.
Not working, got error.
Create a local variable & pass it here.
Set the Default value of created variable as CurrDate()
No, it still get from server date time not client's local date time.
https://success.outsystems.com/Documentation/10/Reference/Logic/Built-in_Functions/Date_and_Time_Built-in_Functions
Thanks, but I already know this and need to find a way. When user open the web form, the create date and time should show client's device date and time not the server.
https://www.outsystems.com/forums/discussion/19474/server-time-date-does-not-match-my-local-time/#Post75847
To me what Ben-J Chen struggling is that's a web app not mobile app, there is no client action, so cannot use CurrDate(), still the device date time need to be used to set a field after page load.
Here is my suggestion:
1. Use javascript to monitor page load event
Ref: https://www.outsystems.com/forums/discussion/18007/event-handlers-on-page-loaded/
Or can use web script javascript: https://www.outsystems.com/learn/lesson/1135/javascript-and-jquery-in-web-applications/
2. In the javascript function, set the value of the hidden text field.
Ref: there are many ways, this is a reference: https://www.outsystems.com/forums/discussion/7626/how-do-you-pass-a-javascript-variable-value-into-application-variable/
Hi Ben-J Chen,
I agree with you, when we set local variable Default value as currDate() it will show us the server date time after page get render, instead of the current system time. To achieve your requirement I did a work-around. Hope that it will help you.
1) Add JQuery script in the Screen level.
SyntaxEditor Code Snippet
$(document).ready(function() { var sysDateTime = new Date(); var month = sysDateTime.getMonth() + 1; var time = (sysDateTime.getHours() < 10 ? '0' : '') + sysDateTime.getHours() + ':' + (sysDateTime.getMinutes() < 10 ? '0' : '') + sysDateTime.getMinutes() + ':' + (sysDateTime.getSeconds() < 10 ? '0' : '') + sysDateTime.getSeconds(); var date = sysDateTime.getFullYear() + '-' + (month < 10 ? '0' : '') + month + '-' + (sysDateTime.getDate() < 10 ? '0' : '') + sysDateTime.getDate(); $('input[id$="DateTimeInput"]').val(date + ' ' + time); });
2) Input Widget with Name - DateTimeInput
3) In the page I introduced a button (for testing purpose) below the input widget, which on click will convert the text value of input widget to datetime using TextToDateTime(DateTime). Here DateTime is the local variable (Text - datatype) assigned as the variable to the input widget.
4) On button click the DateTime value is getting successfully converted to the date time as the Outsystems default datetime format. After this you can pass the converted value as a parameter to table record create action.
Hope you understood my implementation.
Thanks & Regards,
Benjith Sam
Hi Benjith,
Thanks and it is great but I still need to find a way to save client's date and time. I can get client's data time but once I save it cover to server's time.
I also found out one issue, do you have this issue? When I client on the date pop-up to different date.
Ben
Benjith Sam wrote: