System Time
-
I need to display the time in DGLux, however the system time is e.g. Tue Nov 17 HH:MM:SS WAST 2015 - how can I change this format to be Tuesday 17 November 2015 HH:MM for example.
-
Are you trying to display user time or server time?
To display user time, you can have a script element with an output string property -->
function getDayText( num ) {
switch (num) {
case 0 :
return "Sunday";
case 1 :
return "Monday";
case 2:
return "Tuesday";
case 3:
return "Wednesday";
case 4:
return "Thursday";
case 5:
return "Friday";
case 6:
return "Saturday";
}
}function getMonthText( num ) {
switch (num) {
case 0:
return "January";
case 10:
return "November";
default:
return "default";
}
}function pad( num ) {
if( num < 10 )
return "0" + num;
return num;
}var now = new Date();
var output = getDayText( now.getDay() ) + " " + now.getDate() + " " + getMonthText( now.getMonth() ) + " " + now.getHours() + ":" + pad( now.getMinutes() );I am just get reacquainted with some things, but I do not believe there is access to date formatting classes in the DGScript. They do have a date formatter widget that I believe you should be able to bind a running timestamp (a simple script where output=now.toLocaleString(); ) to the date time formatter widget.
-
I'm struggling to get this to work....
Error: Unexpected end of file - just trying to get the week day to work for now. -
That could have been a missing curly brace in the second switch. I found myself thinking the way I suggested wasn't the DGLux way as I was falling asleep last night. I think you may find it easier to have a script triggered by a timer (bind the count to a property of the script, make the script execute on change), sets output = new Date(). Next double click that string property and bind it to the input for a date formatter widget, and you can use normal format strings to get it how you'd like. I think that pattern is:
EEEE D MMMM YYYY at H:NN ==== for 24 hour time
EEEE D MMMM YYYY at L:NN A ==== for AM/PM 12 hour timeI will also go and edit my script to make it easier to get working.
You can find more information on format strings at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/formatters/DateFormatter.html
-
Here is my solution maybe not the neatest script but it works
var date = new Date();
minutes = date.getMinutes();
seconds = date.getSeconds();
hour = date.getHours();
year = date.getFullYear();
day = date.getDay();
month = date.getMonth();
dates = date.getDate();if (minutes < 10)
{
min = "0" + minutes;
}
else
{
min = minutes;
}if (day == 0)
{
strday = "Sunday";
}
if (day == 1)
{
strday = "Monday";
}
if (day == 2)
{
strday = "Tuesday";
}
if (day == 3)
{
strday = "Wednesday";
}
if (day == 4)
{
strday = "Thursday";
}
if (day == 5)
{
strday = "Friday";
}
if (day == 6)
{
strday = "Saturday";
}if (month == 0)
{
strmonth = "January";
}
if (month == 1)
{
strmonth = "February";
}
if (month == 2)
{
strmonth = "March";
}
if (month == 3)
{
strmonth = "April";
}
if (month == 4)
{
strmonth = "May";
}
if (month == 5)
{
strmonth = "June";
}
if (month == 6)
{
strmonth = "July";
}
if (month == 7)
{
strmonth = "August";
}
if (month == 8)
{
strmonth = "September";
}
if (month == 9)
{
strmonth = "October";
}
if (month == 10)
{
strmonth = "November";
}
if (month == 11)
{
strmonth = "December";
}strDated = strday + "," + " " + dates + " " + strmonth + " " + year;
strTimes = hour + ":" + min;