• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1268
  • Last Modified:

Get computer time with Coldfusion

I believe this is a simple question but how do I get local time from a user? Isn't there a way to get the computer variable/time for each user that visits our site? Right now I'm getting the server time


<cfset currentDate = dateFormat(now(), "yyyy/mm/dd")>
<cfset currentTime = timeFormat(now(), "h:mm tt")>

Open in new window

0
brihol44
Asked:
brihol44
  • 2
1 Solution
 
section25Commented:
You can not get the client's computer time with ColdFusion because CF always runs on the server, not the client's pc. The time variable is determined before the page is even sent to the client.

If you want to get the client's time, then you can use javascript. Which is run on the client's pc.

<script type="text/javascript">
var currentTime = new Date()
</script>

and then use javascript functions to get the parts of the date and time that you need. As in:

var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)

0
 
section25Commented:
By the way, when you use javascript to get the client's time, that data is only of any value in javascript. It is not like you could use javascript to get the client's time and then somehow send that back to the server to be used in a Cold Fusion function.
 
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now