format(String, String) is used to change the time zone.
Sample Code:
Visualforce page:
<apex:page controller=”Sample”>
Current Date in US : {!USDateTime}
<br/>
Current Date in UK : {!UKDateTime}
</apex:page>
Apex Controller:
public class Sample {
public String USDateTime {get;set;}
public String UKDateTime {get;set;}
public Sample() {
DateTime temp = System.now();
USDateTime = temp.format(‘MM/dd/yyyy HH:mm:ss’, ‘America/New_York’);
UKDateTime = temp.format(‘MM/dd/yyyy HH:mm:ss’, ‘London’);
}
}
Output:
Cheers!!!