Friday, November 8, 2013

How to get your phing to print out timestamp within your timezone?

Try to get the phing scripts below to echo the right timestamp but always unable to do so. The printed timestamp always based on the UTC timestamp.

        <format pattern="%Y%m%d_%H%M%S" property="build.time">  

 <target name="tstamp"> 
  <echo>build time = ${build.time}</echo> 
Initially, I thought this was phing issue, put the locale attributes insides 'format pattern="%Y%m%d_%H%M%S" property="build.time" locale="Asia/Singapore"', but it doesn't solve the issue.
Spent quite a long time to find the root cause, finally, got the clue on what was happening.

Open the php.ini that your PHP is referring to, edit the locale as your current timezone. For other timezone, please refer to
date.timezone = Asia/Singapore
Rerun your phing with the same piece of code. Voila! it just work like a charm!

No comments: