Connecting Tech Pros Worldwide Forums | Help | Site Map

///Singapore Time now()

Newbie
 
Join Date: Sep 2008
Posts: 20
#1: Oct 4 '08
1. If i need to add into the database time now() of singapore time, how do i do it??


now() + ______



2. If I need to output the time now of singapore , how??

<cfoutput>#now() + __________#</cfoutput>

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Oct 4 '08

re: ///Singapore Time now()


Is this for anywhere throughout the world? You only want to output Singapore time, not the local time?
Newbie
 
Join Date: Sep 2008
Posts: 20
#3: Oct 6 '08

re: ///Singapore Time now()


Yes for sigapore time only

because I want to set now() Singapore time to add to the database



<cfset form.aaDate='#now()#'>

where aaDate is always the singapore time.

thanks
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Oct 6 '08

re: ///Singapore Time now()


Try the DateConvert() function. If the local computer is Singapore time, then that should be OK. If not, you'll have to convert it. TimeZoneInfo() may help too.
Newbie
 
Join Date: Sep 2008
Posts: 20
#5: Oct 8 '08

re: ///Singapore Time now()


The server is a US server
so time now is not accurate

<cfset curDate = Now()>

<cfset utcDate = DateConvert("local2utc+8", curDate)>


How do I add +8 hours to the UTC time??
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Oct 8 '08

re: ///Singapore Time now()


You could try converting the locale using setLocale(). If that doesn't give the desired result, then for want of a better solution, try DateAdd with the number of hours from UTC.
Newbie
 
Join Date: Sep 2008
Posts: 20
#7: Oct 8 '08

re: ///Singapore Time now()


sorry to ask

but is the statement as follow correct??


Expand|Select|Wrap|Line Numbers
  1. <cfset curDate = Now()>
  2. <cfset utcDate = DateConvert("local2utc", curDate)>
  3. <cfoutput>#DATEADD(hh, 8, utcDate)#</cfoutput>
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#8: Oct 8 '08

re: ///Singapore Time now()


The first parameter should be a string and it's "h", not "hh".
Newbie
 
Join Date: Sep 2008
Posts: 20
#9: Oct 8 '08

re: ///Singapore Time now()


I get an error

ts '2008-10-08 09:36:18'} {ts '2008-10-08 16:36:18'}

The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging purposes.

Error Occurred While Processing Request
Variable H is undefined.


Resources:
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#10: Oct 8 '08

re: ///Singapore Time now()


As I said, it should be a string:
Expand|Select|Wrap|Line Numbers
  1. <cfoutput>#DATEADD("h", 8, utcDate)#</cfoutput>
Newbie
 
Join Date: Sep 2008
Posts: 20
#11: Oct 9 '08

re: ///Singapore Time now()


Ok, done, thanks.

A LOT !!

CHEERS! ;-)))))))))))))
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#12: Oct 9 '08

re: ///Singapore Time now()


You're welcome. Glad it's working :)
Reply