function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NaishadhNaishadh 

Difference between actual time and display time for event object

Hi,

 

I am facing very strange issue. I have very simple event component, fetching event records based on userId.

 

I tested the same query in system log and it displays date in proper format but in component it displays different date format. 

 

Output are highlighted in red font.

 

Please guide. 

 

Test Code in System.log with output

 

for(Event e : [Select e.Subject, e.StartDateTime, e.Id, e.EndDateTime From Event e where e.ownerId = :UserInfo.getUserId() and e.ActivityDateTime = Today]) { System.debug(e.Subject); System.debug(e.StartDateTime.format('h:mm a')); System.debug(e.EndDateTime.format('h:mm a')); }

 Output

 

 

20:07:56 DEBUG - Executing:

for(Event e : [Select e.Subject, e.StartDateTime, e.Id, e.EndDateTime From Event e where e.ownerId = :UserInfo.getUserId() and e.ActivityDateTime = Today]) { System.debug(e.Subject);

 

System.debug(e.StartDateTime.format('h:mm a')); System.debug(e.EndDateTime.format('h:mm a')); } 20:07:56 INFO - 20090908143756.721:AnonymousBlock: line 1, column 1: SelectLoop:LIST:SOBJECT:Event 20090908143756.721:AnonymousBlock: line 1, column 15: SOQL query with 2 rows finished in 19 ms

20090908143756.721:

AnonymousBlock: line 2, column 5: Email

20090908143756.721:AnonymousBlock: line 3, column 5: 7:00 AM

20090908143756.721:AnonymousBlock: line 4, column 5: 8:00 AM

20090908143756.721:AnonymousBlock: line 2, column 5: Call

20090908143756.721:AnonymousBlock: line 3, column 5: 7:00 AM

20090908143756.721:AnonymousBlock: line 4, column 5: 8:00 AM

 

Apex Component 

 

<apex:component controller="EventController"> <apex:repeat value="{!eventList}" var="ev"> <li class="event"> <span> <span class="event"> <apex:outputtext value="{0,date,h:mm a}"> <apex:param value="{!ev.StartDateTime}"/> </apex:outputtext> - <apex:outputtext value="{0,date,h:mm a}"> <apex:param value="{!ev.EndDateTime}"/> </apex:outputtext> </span> <apex:outputlink value="/{!ev.Id}?retURL=/home/home.jsp" target="_blank"> {!ev.Subject} </apex:outputlink> </span> </li> </apex:repeat> </apex:component>

 Controller

 

public with sharing class EventController { public EventController() {} public List<Event> getEventList() { return [Select e.Subject, e.StartDateTime, e.Id, e.EndDateTime From Event e where e.ownerId = :UserInfo.getUserId() and e.ActivityDateTime = Today]; } }

 Output

 

# 2:00 PM -3:00 PM Email
# 2:00 PM -3:00 PM Call

 

 

 

 

 

 

 

 

 

 

 

Nick1746323Nick1746323

Most likely a timezone thing.

 

I expect in the system log, it is defaulting to GMT,  and the VF page defaults to the user's timezone. Or maybe the other way round. Try adding "z" to the date format?