sandy1028 Posted June 14, 2011 Share Posted June 14, 2011 Please tell me how to convert system time (PST) to IST. $ date Mon Jun 13 22:11:53 PDT 2011 Link to comment https://forums.phpfreaks.com/topic/239308-convert-system-time-to-ist-time/ Share on other sites More sharing options...
gizmola Posted June 14, 2011 Share Posted June 14, 2011 In PHP you can do this with the datetime object. datetime Link to comment https://forums.phpfreaks.com/topic/239308-convert-system-time-to-ist-time/#findComment-1229404 Share on other sites More sharing options...
gizmola Posted June 14, 2011 Share Posted June 14, 2011 This shows you how to do it (change from one timezone to another) once you created the datetime object with a PST timezone: http://us.php.net/manual/en/datetime.settimezone.php Link to comment https://forums.phpfreaks.com/topic/239308-convert-system-time-to-ist-time/#findComment-1229405 Share on other sites More sharing options...
sandy1028 Posted June 14, 2011 Author Share Posted June 14, 2011 When the time in PST is: Mon Jun 13 23:19:24 PDT 2011 IST time is : Tue Jun 14 11:49:24 IST 2011 $date = new DateTime('2011-06-13 23:17:08', new DateTimeZone('Asia/Calcutta')); echo $date->format('Y-m-d H:i:s') . "\n"; $date->setTimezone(new DateTimeZone('Pacific/Nauru')); //$date->setTimezone(new DateTimeZone('Pacific/Nauru')); echo $date->format('Y-m-d H:i:s') . "\n"; But this will not output the proper result Link to comment https://forums.phpfreaks.com/topic/239308-convert-system-time-to-ist-time/#findComment-1229415 Share on other sites More sharing options...
gizmola Posted June 14, 2011 Share Posted June 14, 2011 You make the dateTime with the timezone for that matches the current time. Then you set the timezone to IST and display it. Link to comment https://forums.phpfreaks.com/topic/239308-convert-system-time-to-ist-time/#findComment-1229691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.