I am trying to convert the timezone with below piece of code which is working fine except AWST timezone.
$date = time();
$timeZone = "AWST";
$dt = new \DateTime();
$dt->setTimestamp($date);
$dt->setTimezone(new \DateTimeZone($timeZone));
echo $dt->format('Y/m/d H:i:s');
If i put $timeZone = "UTC" or something that is working fine. Experts can help me out from this.
I suspect the problem is that you need to specify an IANA time zone ID rather than just an abbreviation. Time zone abbreviations are really problematic for various reasons:
If you can get the right time zone ID for the place you care about, that should give you the right local time throughout history, assuming the time zone data is complete and accurate.
In your case, I believe you want the Australia/Perth time zone. Try this:
$timeZone = "Australia/Perth"
See more on this question at Stackoverflow