Skip to main content
Hello,

So I'm trying to convert the NOW function into pst time zone with the date format of "mm-dd-yyyy 00:00.00 AM/PM" in a text field. I have a workflow that updates a text field with text and time stamps it. I'm just trying to change the date format of NOW, I just don't know hwo to go about it outside of an Apex Class.

This is the current formula:

'Update text'+" "+ text(Now())

Any ideas?

 
2 Antworten
  1. 19. Okt. 2018, 20:09

    Salesforce gives the time in GMT format and by adding 5 hours you'll get PST time.

    The below formula should work for your requirement with few tweaks.

    IF( 

    OR( 

     VALUE( MID( TEXT( MYTIMEFIELD + (5/24)), 12, 2 ) ) = 0, 

     VALUE( MID( TEXT( MYTIMEFIELD + (5/24) ), 12, 2 ) ) = 12 

    ), 

      "12", 

     TEXT( VALUE( MID( TEXT( MYTIMEFIELD + (5/24) ), 12, 2 ) ) 

     - 

    IF( 

    VALUE( MID( TEXT( MYTIMEFIELD + (5/24)), 12, 2 ) ) < 12, 

      0, 

      12 

      ) 

     ) 

    ) 

    & ":" & 

    MID( TEXT( MYTIMEFIELD + (5 /24)), 15, 2 ) 

    & ":" & 

    MID( TEXT( MYTIMEFIELD + (5/24) ), 18, 2 ) 

    & " " & 

    IF( 

     VALUE( MID( TEXT( MYTIMEFIELD + (5/24)), 12, 2 ) ) < 12, 

     "AM", 

     "PM" 

    )

    Replace : MYTIMEFIELD with your Date & Time field.

    If it answer your question, mark as solved.

     

    Sathish P