TimeZone Extension Attribute

New Contributor

I couldn't find any extension attribute in the templates or in any forum for showing the local timezone of a computer in jamf, so I wrote my own.


It's just a simple script to pull the info from the localtime file, and cut off the first part that is always the same, then return the result to the jss.


example: TimeZone:/America/New_York



# Extension attribute to return current TZ
localtime=`/bin/ls -n /etc/localtime`
echo "<result>$TimeZone</result>"
exit 0


Here's the full .XML file for importing to jamf directly:

<?xml version="1.0" encoding="UTF-8"?><extensionAttribute>
<description>gets time zone</description>
# Extension attribute to return current TZ&#13;
localtime=`/bin/ls -n /etc/localtime`&#13;
echo "&lt;result&gt;$TimeZone&lt;/result&gt;"&#13;
exit 0&#13;

Feel free to use as needed! 


New Contributor

The digital transformation consultant improves organization efficiency by implementing Enterprise software (ERP, CRM, HR, CX, HCM, business intelligence). We implement ERP solutions that enhance customer experience, improve efficiency and skyrocket growth. Our objective is to deliver ERP solutions that increase ROI and minimize risk. If You need ERP consultant then contact us.

Contributor III

I was talking with my co-worker about this on Friday.  Were you listening @user-dKGrgHyYDI like Alexa? 😁

Thx for the script

New Contributor III

Is there a way to get the specific time zone? (i.e. EST, PST)

Ideally going for a more generic grouping than specific locations.

New Contributor

I changed this slightly to pipe this to awk


# Extension attribute to return current TZ
localtime=`/bin/ls -n /etc/localtime | awk -F"zoneinfo/" '/zoneinfo/{print $2}'`
echo "<result>$localtime</result>"
exit 0


awk instead.