Hi All,

I have a business requirement , where I have to do some validation based on user's local date time .I need a way to convert server saved time to users local date time and implement some validation.

Is there any way to do that in outsystems?

Thanks

Hi Pranav Pandey,

Maybe you want to check this forge component:

https://www.outsystems.com/Forge/component/500/time-zone/

Cheers!

Marco Arede wrote:

Hi Pranav Pandey,

Maybe you want to check this forge component:

https://www.outsystems.com/Forge/component/500/time-zone/

Cheers!

Thanks Marco Arede, I will try it :)


Hi Marco Arede,

I question here .How do we get the users local datetime and timezone (not the server time) automatically ?

Hi, you  can try to use the CurrDateTime(). In the client-side it will retun the device date and time.

You can see here.

Deise Silva wrote:

Hi, you  can try to use the CurrDateTime(). In the client-side it will retun the device date and time.

You can see here.

Hi Deise Silva,

Its not returning my systems time or my browser time . Its returning the server date-time .Please find the screenshot in the attachment.



Pranav Pandey wrote:

Hi Marco Arede,

I question here .How do we get the users local datetime and timezone (not the server time) automatically ?

var time = Date.now || function() {
  return +new Date;
};

time();

You can use JS.

Solution

Pranav Pandey,

Adding to what assif_tiger wrote, after you get the browser's local date/time via JS you will need to send it to the server (assign it as the value to a hidden input and submit it with the remainder of your data, for instance).

Then you can use the TimeZone component Marco Arede suggested to do the conversions. An interesting article on this topic (that includes guidelines on how to implement it) can be found here.

Solution

Jorge Martins wrote:

Pranav Pandey,

Adding to what assif_tiger wrote, after you get the browser's local date/time via JS you will need to send it to the server (assign it as the value to a hidden input and submit it with the remainder of your data, for instance).

Then you can use the TimeZone component Marco Arede suggested to do the conversions. An interesting article on this topic (that includes guidelines on how to implement it) can be found here.

Thank you very much Jorge Martins.

So basically in order to assign the offset value from the java-script, we need to manually trigger a action that will assign it to a variable ,(I m using session variable to store the offset value as i need to do calculation base on current server date-time).

Thank you all for helping me out , really appreciated 

:)