16 votes

How can I get my correct current local time?

This code will get you the local time for the logged in user, by leveraging the timezone offset to subtract/add from GMT. It's even smart enough to account for Daylight Saving. TimeZone tz = UserInfo....
Sebastian Kessel's user avatar
7 votes

How can I get my correct current local time?

DateTime values are represented by an epoch time in GMT, and converted to the appropriate date/time when requested via the appropriate methods. System.debug, coincidentally, always displays GMT. Try ...
sfdcfox's user avatar
  • 490k
7 votes
Accepted

AutoSave information every 5 minutes- How to implement?

You can use <apex:actionPoller/> to implement your requirement Visualforce <apex:page controller="autoSaveController"> <apex:form id="form1"> <apex:actionPoller action="{!save}"...
Santanu Boral's user avatar
6 votes

How can I get my correct current local time?

DateTime usually shows the time in GMT. Format function retrieves the time based on user's timezone defined in Salesforce. Let's say, this timezone is CST. So, format() or formatLong() (Converts the ...
Santanu Boral's user avatar
6 votes

Format AM/PM DateTime to 24 hour time

The closest you can get to this is by using the FormatDate AMPscript function with ISO pattern: set @dateString = "9/14/2019 4:37:57 PM" set @dateISO = FormatDate(@dateString,"iso") %%=v(@dateISO)=%...
zuzannamj's user avatar
  • 14.4k
4 votes

How to Get the Current System Time using SOQL

If you cannot use Apex, and need to use SOQL only, then binding is not allowed. Which means you cannot use system.now(); With that in mind, you can use Date Literals, such as YESTERDAY, TODAY, ...
Matheus Gonçalves's user avatar
4 votes
Accepted

How to output time field in lightning component

You can use the Formatted Date Time <lightning:formattedDateTime> or Formatted Time <lightning:formattedTime> component to display a formatted time value. Your Code using the Formatted ...
Jigar Shah's user avatar
  • 1,148
4 votes
Accepted

Time field based on TimeZone

The Time field type was created specifically to have a field that would be a time value independent of date. If your business hours are 08:00 - 18:00, regardless of the date, let's say, this is the ...
pchittum's user avatar
  • 19.7k
4 votes

Salesforce displaying Time custom field in GMT instead of User's timezone

All DateTimes in Salesforce are stored as GMT/UTC so that they can easily be shifted based on a user's timezone (a necessity in any organization where users are logging in from multiple time zones). ...
nbrown's user avatar
  • 4,013
4 votes
Accepted

What is the best way to correctly create a string with a time queried from SOQL which needs to be displayed to Germans?

Simply use Salesforce's TimeZone class, and specifically the TimeZone.getOffset method. You can probably do something like: TimeZone germanyTZ = TimeZone.getTimeZone('Europe/Berlin'); System.debug(...
Phil W's user avatar
  • 36.1k
4 votes
Accepted

How do I use a TIME literal in a SOQL Query?

I haven't been able to find any relevant documentation for this, so it's time to get empirical. I created a Test_Time__c field (field type Time) on Account in my dev edition org, found myself a record ...
Derek F's user avatar
  • 61.5k
4 votes

How do I use a TIME literal in a SOQL Query?

If you query out Actual_Arrival_Time_D__c from Container__c you can confirm the formatting. When I query a time value I see them in the format 09:45:25.000Z. I have to add the Z to the end of the time ...
wbfredrickson's user avatar
4 votes
Accepted

Time-to-Text conversion in Flows

The reason for the weirdness is that the Time field type is not supported in Flow Builder Time Custom Field outlines its limitations Be aware of the following limitations when using a time field type....
Kris Goncalves's user avatar
4 votes

APEX - Loop and SOQL - Performance Question (Time and Space Complexity)

Sadly enough this question itself is too academical for this stackexchange probably but I'll go with real life + best practices response. So the answer is... number 1. Thank you good bye. But ...
user1974566's user avatar
  • 2,315
3 votes
Accepted

Time Field on Data Load - "value not of required type: 5:33 PM"

I was experiencing this same issue but managed to get the import to work by appending .000Z to the end of the hh:mm:ss format As an example: Start Time End Time 14:00:00.000Z 16:00:00.000Z 14:00:...
Jwok's user avatar
  • 767
3 votes

Formating the new time field in Visualforce

Pure VisualForce solution, if you need to do this without any Apex: {!HOUR(Object__c.Time_Field__c)}: <apex:outputText value="{0,number,00}"> <apex:param value="{!Minute(Object__c....
Emily Holden's user avatar
3 votes
Accepted

Formula for writing a specific Day of Week date value?

A quick Google revealed this: CASE( MOD(TODAY() - DATE(1900, 1, 8), 7), 0, TODAY() + 7, 1, TODAY() + 6, 2, TODAY() + 5, 3, TODAY() + 4, 4, TODAY() + 3, 5, TODAY() + 2, 6, TODAY() + 1, DATE(9999,01,...
Keith C's user avatar
  • 136k
3 votes
Accepted

Time comparison in Apex

You can use the Datetime type here despite your comments to the contrary. If you need a List<Time>, you can call time() on each instance (similar to date(), year(), etc.). Datetime pointer, max;...
Adrian Larson's user avatar
  • 150k
3 votes
Accepted

TIMENOW() subtraction

TimeNow() returns the current time in GMT. When the user views a Time field it's converted to their local timezone, but the value in the field is also always stored as GMT. The almost-84 million ...
IllusiveBrian's user avatar
3 votes
Accepted

Format AM/PM DateTime to 24 hour time

You can get exactly your desired output using the following: %%[ SET @time = "9/14/2019 4:37:57 PM" SET @formatted = Replace(FormatDate(@time, "YYYYMMDDT","HHMMSS"),' ','') ]%% %%=v(@formatted)=%% ...
Cameron Robert's user avatar
3 votes
Accepted

How to get time left on OrgPartition from Platform Cache?

From Salesforce Support: Unfortunately, there is no such method which can calculate the time left from Platform Cache for a particular partition.
S.B.'s user avatar
  • 2,071
3 votes

In Apex, how can I format Datetime for Europe/Berlin without assuming the input value is GMT?

One option is to take the UTC Datetime value, convert it to Berlin time then extract the date and time (using the dateGmt() and timeGmt() methods on Datetime) values and present these as separate Date ...
Phil W's user avatar
  • 36.1k
3 votes
Accepted

In Apex, how can I format Datetime for Europe/Berlin without assuming the input value is GMT?

With thanks to @Phil W whose feedback put me on the right track, I've modified my code to the following which seems to work: public String formatForGermany(Datetime targetTime) { return this....
Brian Kessler's user avatar
2 votes
Accepted

Account Time Settings

Server time is in CST. Stack 4 is on Mountain Time. Daylight savings is not observed. What is the system timezone in Marketing Cloud and does it consider DST?
Jackson Chen's user avatar
  • 4,697
2 votes
Accepted

Storing time-stamps with millisecond precision

Yes, unfortunately second precision is as close as you can get, especially for audit fields (created date, last modified date). Using getTime will allow you to get closer to millisecond precision, so ...
sfdcfox's user avatar
  • 490k
2 votes
Accepted

Cannot deserialize instance of time from VALUE_STRING value

This is probably a bug, and I'd recommend contacting Salesforce Support (If you haven't already). Heres a repo I wrote using a custom object (Test__c, with a single time field, Some_Time__c). It ...
battery.cord's user avatar
  • 8,825
2 votes

Merge Date & Time field in to datetime field using formula field

You can handle this in Apex like this: DateTime dt = DateTime.newInstance(myDate, myTime);
Mahesh Khandelwal's user avatar
2 votes
Accepted

Process builder conditions when custom date/time is NOW()

Criteria are only evaluated at the moment a record is saved. This means that your rule only works if the user saves the record with the exact second in the reminder time field. Instead, make the ...
sfdcfox's user avatar
  • 490k
2 votes
Accepted

CreatedDate of new record (Time)

All DateTime values are always saved in GMT, no matter what the user or org's time zone is set to. Further, all values are always retrieved in GMT. The user interface (e.g. Classic, Lightning) will ...
sfdcfox's user avatar
  • 490k
2 votes

lightning:input type="time" displays millisecond value when editing object

So I managed to come up with a hacky JavaScript solution that solved the issue. Not exactly an ideal solution but it works for the time being. In my LightningDriverRow component I added an init ...
HoldenIsCoding's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible