+ Start a Discussion
WPCMSWPCMS 

NOW() Showing Wrong Time

I am currently in the Eastern time zone of the United States.

 

My current time is 9:50 a.m.

 

When I use the NOW() funtion it shows the correct date but not the correct time. It shows 13:50 (1:50 p.m.).

 

I checked the Company default Time Zone and it says

(GMT-4:00) Easter Daylight Time (America/New_York).

 

Why is it off?

 

Thank you in advnace.

Best Answer chosen by Admin (Salesforce Developers) 
cldavecldave

Having had the same issue this morning , i found a simple solution to use NOW() function and get proper time according to time zone

 

I'm EST and there is a +4h difference with GMT

 

Using formula NOW() -4 would take out 4 days and not 4 hours , so what i did is:

 

1 day/24h = 0.0416666666 (value of 1 hour)

0.041666666(value of 1 hour) x 4 (how many hours difference my timezone to GMT) = 0.166666664

 

then I used (NOW () - 0.166666664) and that gave me current time

 

hope it helps

 

 

 

Dave

All Answers

SeAlVaSeAlVa

Have you checked YOUR timezone? 

 

Name->Setup->My Personal Information->Personal Information

 

Time Zone

 

Regards

 

 

WPCMSWPCMS

I am showing the same as the company organization, GMT -4:00.

 

Now it is 4 hours a head!

Current time: 12:20

NOW Time:

2012-04-26 16:20:11Z
matermortsmatermorts

This is probably not immensely helpful to solving your issue, but I just did a quick google search (which I'm sure you've already done), and found this post on Stack Overflow. Maybe it's somewhat helpful, if you haven't seen it yet.

 

I'm very interested to know if you ever get a working solution.

SkyhSkyh

Try, System.Now()

SwarnasankhaSwarnasankha

If you are using the NOW() function in a formula field, the timezone conversion will NOT be performed and the date calculation will be off by the number of hours you are shifted away from GMT.

WPCMSWPCMS

What I am doing in my formula is the following:

ext( Year(TODAY()))&
IF(LEN(TEXT(MONTH(TODAY())))=1,"0"&TEXT(MONTH(TODAY())),TEXT(MONTH(TODAY())))&
IF(LEN(TEXT(DAY(TODAY())))=1,"0"&TEXT(DAY(TODAY())),TEXT(DAY(TODAY())))&MID(TEXT(NOW()),12,2)&MID(TEXT(NOW()),15,2)& $User.Initials__c

 It is the date then current time then initials of user

Example output 

201205031556ABC

 

Date is 20120503

Time 1556 (which is wrong it should be 1156)

Initials ABC

 

Any other ideas on how to handle this formula?

cldavecldave

Having had the same issue this morning , i found a simple solution to use NOW() function and get proper time according to time zone

 

I'm EST and there is a +4h difference with GMT

 

Using formula NOW() -4 would take out 4 days and not 4 hours , so what i did is:

 

1 day/24h = 0.0416666666 (value of 1 hour)

0.041666666(value of 1 hour) x 4 (how many hours difference my timezone to GMT) = 0.166666664

 

then I used (NOW () - 0.166666664) and that gave me current time

 

hope it helps

 

 

 

Dave

This was selected as the best answer
WPCMSWPCMS
That worked! Thank you for the post.
cldavecldave

You are welcome , glad it could help someone else :)