Question
Problem with Local Time and Date
Hi,
I have an application that uses now(). However, I think this function takes the time from the users computer, but the server is different. Therefore, when comparing times, it gets it all wrong.
How can I use GMT (United Kingdom) as my primary time and date format. Is there any way I can convert a date (either from the server or users computer) to read as a proper GMT time??
I have looked at the following code:
<h3>LSParseDateTime Example - returns a locale-specific date/time object</h3>
<!--- loop through a list of locales and show date values for Now()--->
<cfdump var="#Server.Coldfusion.SupportedLocales#" />
<cfloop list="#Server.Coldfusion.SupportedLocales#" index="locale" delimiters=",">
<cfset variables.oldlocale = SetLocale(locale) />
<cfoutput>
<p><strong>#locale#</strong></p>
<p>Locale-specific formats:</p>
<ul>
<li>#LSDateFormat(Now(), "mmm-dd-yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "mmmm d, yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "mm/dd/yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "d-mmm-yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "ddd, mmmm dd, yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "d/m/yy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now())# #LSTimeFormat(Now())#</li>
</ul>
<p>Standard Date/Time: #LSParseDateTime("#LSDateFormat(Now())# #LSTimeFormat(Now())#")#</p>
</cfoutput>
</cfloop>
However, all of the time returns 10:45!! Regardsless of what locale each is...is this correct? I'm really confused.
If someone could give me a primer on this for 2 minutes that would be great. I just want dates that sync up together regardless of where the user is in the world because my application is dependant on comparing these times.
Thanks,
Mikey.
I have an application that uses now(). However, I think this function takes the time from the users computer, but the server is different. Therefore, when comparing times, it gets it all wrong.
How can I use GMT (United Kingdom) as my primary time and date format. Is there any way I can convert a date (either from the server or users computer) to read as a proper GMT time??
I have looked at the following code:
<h3>LSParseDateTime Example - returns a locale-specific date/time object</h3>
<!--- loop through a list of locales and show date values for Now()--->
<cfdump var="#Server.Coldfusion.SupportedLocales#" />
<cfloop list="#Server.Coldfusion.SupportedLocales#" index="locale" delimiters=",">
<cfset variables.oldlocale = SetLocale(locale) />
<cfoutput>
<p><strong>#locale#</strong></p>
<p>Locale-specific formats:</p>
<ul>
<li>#LSDateFormat(Now(), "mmm-dd-yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "mmmm d, yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "mm/dd/yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "d-mmm-yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "ddd, mmmm dd, yyyy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now(), "d/m/yy")# #LSTimeFormat(Now())#</li>
<li>#LSDateFormat(Now())# #LSTimeFormat(Now())#</li>
</ul>
<p>Standard Date/Time: #LSParseDateTime("#LSDateFormat(Now())# #LSTimeFormat(Now())#")#</p>
</cfoutput>
</cfloop>
However, all of the time returns 10:45!! Regardsless of what locale each is...is this correct? I'm really confused.
If someone could give me a primer on this for 2 minutes that would be great. I just want dates that sync up together regardless of where the user is in the world because my application is dependant on comparing these times.
Thanks,
Mikey.
