API Questions on Kentico API.
Version 6.x > API > How to show local time from my computer on Editable Text? View modes: 
User avatar
Member
Member
lethanhclub-live - 12/13/2012 10:11:43 PM
   
How to show local time from my computer on Editable Text?
Hi all,

Can anyone help me to get local time (DateTime) from my computer?
I want to use Editable Text webpart to do.
Please look at the following image:
User image

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/14/2012 3:23:56 AM
   
RE:How to show local time from my computer on Editable Text?
Hello,

Since Kentico is a ASP.NET application which runs on a server, you need to use javascript for a client-side scripting and getting current computer time like this:
<script type="text/javascript">

var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()

if (minutes < 10)
minutes = "0" + minutes

document.write("<b>" + hours + ":" + minutes + " " + "</b>")

</script>

You can place this script into the Javascript web part.

Best regards,
Jan Hermann

User avatar
Member
Member
lethanhclub-live - 12/15/2012 3:59:13 AM
   
RE:How to show local time from my computer on Editable Text?
Hello Jan,

I will try.

thank you Jan.

User avatar
Member
Member
lethanhclub-live - 12/18/2012 7:41:03 AM
   
RE:How to show local time from my computer on Editable Text?
It works fine. Thank you very much! :)