Unity 3D Game Engine – Real Time In Game Clock

1. Hiearchy> GUI Text, choose a font or download it from http://www.1001freefonts.com/3d-fonts.php

2. Hierarchy> Main Camera, attach ‘Clock.js’

Clock.js


#pragma strict

var ClockText  : GUIText;  // Hierarchy DRAG E DROP over var GUI Text in Inspector  
private var dt = Date();
 
 
function Update () {
 
var day = dt.Now.Day;
var month = dt.Now.Month;
var year = dt.Now.Year;
var hours = dt.Now.Hour;
var minutes = dt.Now.Minute;
var seconds = dt.Now.Second;
 
ClockText.text = day + " " + month + " " + year + " " + hours + " " + minutes + " " + seconds;
 
}

Hierarchy> Main Camera> Inspector> Clock.js, assign GUI Text

Today, the result is:

16 5 2014 10 40 32