Count Down Timer.... (per second)

How would I add a count down timer that counts down per second and displays how many seconds left?

My Current Code: (yes I know that the Update function is incorrect but I'm just testing the decrementing)

var seconds = 60;

function Update () {
    seconds --;
    var a = GameObject.Find ("Timer");
    var testMesh : TestMesh = a.GetComponent(TextMesh);
    testMesh.text = seconds.ToString ();

When I used this code.... it went way too fast and went to negatives.

So can someone tell me a professional script (stops at zero and changes per SECOND)? Thanks!

Here's another method...it only fires once per second, and stops when done, so it doesn't use any unnecessary CPU cycles:

var seconds = 60;
private var textMesh : TextMesh;

function Start () {
    textMesh = GameObject.Find ("Timer").GetComponent(TextMesh);
    textMesh.text = seconds.ToString();
    InvokeRepeating ("Countdown", 1.0, 1.0);
}

function Countdown () {
    if (--seconds == 0) CancelInvoke ("Countdown");
    textMesh.text = seconds.ToString();
}

Something like this should work:

var endTime : float;
var textMesh : TextMesh;

function Start()
{
    endTime = Time.time + 60;
    textMesh = GameObject.Find ("Timer").GetComponent(TextMesh);
    textMesh.text = "60";
}

function Update()
{
    var timeLeft : int = endTime - Time.time;
    if (timeLeft < 0) timeLeft = 0;
    textMesh.text = timeLeft.ToString();
}

Here is my adapted solution using Unity 5 and following the video at Count Down Timer in Unity 3D - YouTube

My solution is in my “GameController” script, so the formatting (position, font, type, etc) are set in the inspector window. Also, the “GameOver” function I call, is inside the “GameController” script. Make sure you’ve got Using UnityEngine.UI listed at the top. I’ve also place the “(int)” in front of time remaining because I wanted it to countdown per second vs the timer showing per frame. Hope this helps!

	public Text cdtimerText;

	public float timeRemaining;

	// Use this for initialization
	void Start () {
		cdtimerText.text = "";

	}
	
	void Update ()
	{
		// Functional game countdown timer
		timeRemaining -= Time.deltaTime;
		if (timeRemaining > 0) {
			cdtimerText.text = "TIME: " + (int)timeRemaining;
		} else {
			cdtimerText.text = "TIME'S UP!";
			GameOver ();

		}
	}