-
Hi
I want to be able to use the server date to reveal sections of a SWF over a period of a month. I don't want to use the users system date/time.
Any ideas how I can pull in a consistent date/time reference that isn't user dependent?
Thanks
Wayne Johnson
-
Firmly Fastened to the Milk Sac of Misanthropy
Use PHP, if your server supports it.
Create a php file named day.php with the following content:
<?php
$day = date("j", time());
print "_root.day=$day";
?>
To pull the date from flash place the following in the first frame:
loadVariablesNum("http://www.wherever.com/folder/day.php", "POST");
Now a variable named 'day' is available on the root timeline. This variable represents the day of the month with no leading zero. Naturally, you can pull additional server date/time info than just the day of the month. More info on php's date function is available here.
Sem
-
Server Date/Time?
Hi Sem
Thanks for the response. I can't use PHP unfortunately.
Cheers
Wayne
Originally posted by Sem
Use PHP, if your server supports it.
Create a php file named day.php with the following content:
<?php
$day = date("j", time());
print "_root.day=$day";
?>
To pull the date from flash place the following in the first frame:
loadVariablesNum("http://www.wherever.com/folder/day.php", "POST");
Now a variable named 'day' is available on the root timeline. This variable represents the day of the month with no leading zero. Naturally, you can pull additional server date/time info than just the day of the month. More info on php's date function is available here.
Sem
-
Firmly Fastened to the Milk Sac of Misanthropy
Do you have any other server-side scripting languages available (ASP, Perl?)
Sem.
-
you don't need access to middleware to do that - use the UTC functions in javascript to get the same result.
they are set to universal time - GMT.
here's some code to help you out:
Code:
<script language = "Javascript">
function makeArray() {
for (i = 0; i<makeArray.arguments.length; i++)
this[i + 1] = makeArray.arguments[i];
}
function makeArray0() {
for (i = 0; i<makeArray0.arguments.length; i++)
this[i] = makeArray0.arguments[i];
}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
var months = new makeArray ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var days = new makeArray0('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var today = new Date();
var hour = today.getUTCHours();
var minute = today.getUTCMinutes();
var day = days[today.getUTCDay()];
var date = today.getUTCDate();
var month = today.getUTCMonth() + 1;
var year = y2k(today.getYear());
if (hour > 12) {var am_pm = "pm" ; var hour = hour-12;} else { var am_pm = "am" ; }
if ((minute >= 0) && (minute <= 9)) {var minute = "0" + minute ; }
visit = hour + ":" + minute + ' ' + am_pm + ', ' + day + ' ' + date + ' ' + months[month] + ' ' + year ;
document.write (visit) ;
</script>
returns time stamp in this format: 5:11 pm, Tuesday 9 Jul 2002
cya
Henry
-
u can also do the users time as well in flash
-
Server Date/Time?
Hi Henry
I think you'll find that the client side javascript date declaration is
the users system date and the UTC is just an offset of that. I've tried
testing and it is dependent on user system date.
Looks like I'm going to use java anyway, so thanks for the responses.
Cheers
Wayne
Originally posted by BIG jolt
you don't need access to middleware to do that - use the UTC functions in javascript to get the same result.
they are set to universal time - GMT.
here's some code to help you out:
Code:
<script language = "Javascript">
function makeArray() {
for (i = 0; i<makeArray.arguments.length; i++)
this[i + 1] = makeArray.arguments[i];
}
function makeArray0() {
for (i = 0; i<makeArray0.arguments.length; i++)
this[i] = makeArray0.arguments[i];
}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
var months = new makeArray ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var days = new makeArray0('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var today = new Date();
var hour = today.getUTCHours();
var minute = today.getUTCMinutes();
var day = days[today.getUTCDay()];
var date = today.getUTCDate();
var month = today.getUTCMonth() + 1;
var year = y2k(today.getYear());
if (hour > 12) {var am_pm = "pm" ; var hour = hour-12;} else { var am_pm = "am" ; }
if ((minute >= 0) && (minute <= 9)) {var minute = "0" + minute ; }
visit = hour + ":" + minute + ' ' + am_pm + ', ' + day + ' ' + date + ' ' + months[month] + ' ' + year ;
document.write (visit) ;
</script>
returns time stamp in this format: 5:11 pm, Tuesday 9 Jul 2002
cya
Henry
-
flash will return only local client side date.
wyane, i think your right about UTC - you need to use getTimezoneOffset() to determine the time difference between the local time and universal time
btw, how would you use java to do the same??
cheers
Henry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|