 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
nwongfeiying Grandmaster Cheater
Reputation: 2
Joined: 25 Jun 2007 Posts: 695
|
Posted: Sun Oct 03, 2010 1:04 pm Post subject: JavaScript: Date() |
|
|
I have no idea why it won't work.
Here is the HTML file:
Code: | <html>
<head>
<script src="./DateTime.js" type="text/javascript"></script>
</head>
<body onLoad="fnUpdate()">
<form name="form">
<textarea cols="50" name="clock" rows="5">Loading...</textarea>
</form>
</body>
</html> |
Here is the JavaScript:
Code: | function fnTimeZone(amTimeZone, amOffSet, amDaylightSavings)
{
this.DateTime = new Date();
this.TimeZone = amTimeZone;
this.OffSet = amOffSet;
this.DaylightSavings = amDaylightSavings;
}
function fnClockString(amDateTime)
{
var sgBuffer, dtAMPM;
var dtYear = amDateTime.getUTCFullYear();
var dtMonth = amDateTime.getUTCMonth() + 1;
var dtDay = amDateTime.getUTCDate();
var dtHour = amDateTime.getUTCHours();
var dtMinute = amDateTime.getUTCMinutes();
var dtSecond = amDateTime.getUTCSeconds();
dtYear = dtYear.toString();
if(0 <= dtHour && dtHour < 12)
{
dtAMPM = "AM";
} else {
dtAMPM = "PM";
dtHour -= 12;
if(dtHour === 0)
{
dtHour = 12;
}
}
if(dtMinute < 10)
{
dtMinute = "0" + dtMinute;
}
if(dtSecond < 10)
{
dtSecond = "0" + dtMinute;
}
sgBuffer = dtMonth + '/' + dtDay + '/' + dtYear; // dtYear or dtYear.substr(2, 2)
sgBuffer = sgBuffer + ' ' + dtHour + ':' + dtMinute + ':' + dtSecond + ' ' + dtAMPM;
return sgBuffer;
}
function fnUpdate()
{
// Time zones
var ayDateTimes = new Array
(
new fnTimeZone("SFO: ", -8, 1), new fnTimeZone("NYC: ", -5, 1)
);
var otDateTime = new Date();
// Handle daylight savings
var otStartDaylightSavings = new Date(otDateTime.getFullYear(), 3, 1);
while(otStartDaylightSavings.getDay() !== 0)
{
otStartDaylightSavings.setDate(otStartDaylightSavings.getDate() + 1);
}
var otEndDaylightSavings = new Date(otDateTime.getFullYear(), 9, 31);
while(otEndDaylightSavings.getDay !== 0)
{
otEndDaylightSavings.getDate(otEndDaylightSavings.getDate() - 1);
}
var bDaylightSavings;
if(otStartDaylightSavings < otDateTime && otDateTime < otEndDaylightSavings)
{
bDaylightSavings = 1; // True
} else {
bDaylightSavings = 0; // False
}
for(var nDateTimes = 0; nDateTimes < ayDateTimes.length; nDateTimes++)
{
if(ayDateTimes[nDateTimes].DaylightSavings == 1 && bDaylightSavings == 1)
{
ayDateTimes[nDateTimes].OffSet++;
}
}
// Get GMT time then apply offsets
var otGMT = new Date();
for(nDateTimes = 0; nDateTimes < ayDateTimes.length; nDateTimes++)
{
ayDateTimes[nDateTimes].DateTime = new Date(otGMT.getTime() + otGMT[nDateTimes].OffSet * 3600 * 1000);
}
window.document.form.clock.value = ayDateTimes[0].TimeZone + fnClockString(ayDateTimes[0].DateTime);
} |
|
|
Back to top |
|
 |
AhMunRa Grandmaster Cheater Supreme
Reputation: 27
Joined: 06 Aug 2010 Posts: 1117
|
Posted: Sun Oct 03, 2010 5:45 pm Post subject: |
|
|
It crashes Firefox every time. Try posting it in Programming Section. This looks like a job for Wiccan.
_________________
<Wiccaan> Bah that was supposed to say 'not saying its dead' lol. Fixing >.> |
|
Back to top |
|
 |
Arma103 How do I cheat?
Reputation: 0
Joined: 25 Sep 2020 Posts: 6
|
Posted: Fri Sep 25, 2020 5:46 am Post subject: Re: JavaScript: Date() |
|
|
You try changing this "if(0 <= dtHour && dtHour < 12)" to "if(dtHour >=0 && dtHour < 12)"
|
|
Back to top |
|
 |
avangers Newbie cheater
Reputation: 0
Joined: 20 Sep 2017 Posts: 18
|
Posted: Sat Dec 05, 2020 5:23 am Post subject: |
|
|
maybe this helps you out for showing the date in java script
Code: |
function getTodaysDate() {
var now = new Date();
var days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var date = ((now.getDate() < 10) ? "0" : "") + now.getDate();
var today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
now.getFullYear();
return (today);
}
|
_________________
Welcome everyone who sees this under my post or reply. I want to ask you to check out the little message on the art zone, rate it, and if you wish to contact me on my email to be able to get your advertisement picture or anything else you want to for a low price is added to the post regards avangers |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|