vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: [F] Need help with code - View Topic
Topic Rating: *****
Printable View
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
[F] Need help with code (21st Feb 08 at 7:26pm UTC)
I need help with this code, it is in 24 hours and I want it to be in 12

Code:
 
  1. <SCRIPT LANGUAGE = "JavaScript">
  2. <!-- Begin Script
  3.  
  4. //Display Time of last visit script
  5.  
  6.  
  7. var expDays = 30;
  8. var exp = new Date();
  9. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  10.  
  11. function When(info){
  12. // When
  13. var rightNow = new Date()
  14. var WWHTime = 0;
  15. WWHTime = GetCookie('WWhenH')
  16.  
  17. WWHTime = WWHTime * 1
  18.  
  19. var lastHereFormatting = new Date(WWHTime); // Date-i-fy that number
  20. var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
  21. var lastHereInDateFormat = "" + lastHereFormatting; // Gotta use substring functions
  22. var dayOfWeek = lastHereInDateFormat.substring(0,3)
  23. var dateMonth = lastHereInDateFormat.substring(4,10)
  24. var hours = "" + lastHereFormatting.getHours()
  25. var year = lastHereFormatting.getYear()
  26. if (year < 1000) year+=1900
  27. var minutes = "" + lastHereFormatting.getMinutes()
  28. if (minutes.substring(0,1) == minutes){
  29. minutes = "0" + minutes
  30. }
  31. var WWHText = dayOfWeek + ", " + dateMonth + " " + year + " at " + hours + ":" + minutes// display
  32.  
  33. SetCookie ("WWhenH", rightNow.getTime(), exp)
  34.  
  35. return WWHText;
  36. }
  37.  
  38. function Count(info){
  39. var psj=0;
  40. // How many times
  41. var WWHCount = GetCookie('WWHCount')
  42. if (WWHCount == null) {
  43. WWHCount = 0;
  44. }
  45. else{
  46. WWHCount++;
  47. }
  48. SetCookie ('WWHCount', WWHCount, exp);
  49.  
  50.  
  51. return WWHCount+1;
  52. }
  53.  
  54.  
  55.  
  56. function set(){
  57. // VisitorName = prompt("Who are you?", "Nada");
  58. // SetCookie ('VisitorName', VisitorName, exp);
  59. SetCookie ('WWHCount', 0, exp);
  60. SetCookie ('WWhenH', 0, exp);
  61. }
  62.  
  63. function getCookieVal (offset) {
  64. var endstr = document.cookie.indexOf (";", offset);
  65. if (endstr == -1)
  66. endstr = document.cookie.length;
  67. return unescape(document.cookie.substring(offset, endstr));
  68. }
  69.  
  70. function GetCookie (name) {
  71. var arg = name + "=";
  72. var alen = arg.length;
  73. var clen = document.cookie.length;
  74. var i = 0;
  75. while (i < clen) {
  76. var j = i + alen;
  77. if (document.cookie.substring(i, j) == arg)
  78. return getCookieVal (j);
  79. i = document.cookie.indexOf(" ", i) + 1;
  80. if (i == 0) break;
  81. }
  82. return null;
  83. }
  84.  
  85. function SetCookie (name, value) {
  86. var argv = SetCookie.arguments;
  87. var argc = SetCookie.arguments.length;
  88. var expires = (argc > 2) ? argv[2] : null;
  89. var path = (argc > 3) ? argv[3] : null;
  90. var domain = (argc > 4) ? argv[4] : null;
  91. var secure = (argc > 5) ? argv[5] : false;
  92. document.cookie = name + "=" + escape (value) +
  93. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  94. ((path == null) ? "" : ("; path=" + path)) +
  95. ((domain == null) ? "" : ("; domain=" + domain)) +
  96. ((secure == true) ? "; secure" : "");
  97. }
  98.  
  99. function DeleteCookie (name) {
  100. var exp = new Date();
  101. exp.setTime (exp.getTime() - 1);
  102. // This cookie is history
  103. var cval = GetCookie (name);
  104. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  105.  
  106. }
  107. // End Script -->
  108. </SCRIPT>
  109. <center><script>
  110. if (Count()==1){
  111. document.write("This is your 1st visit to our page")
  112. When()
  113. }
  114. else if (Count()>1)
  115. document.write("Welcome back. Your last visit was on <b>" + When() +"</B>.")
  116. </script></center>
  117. <div align='center'>
  118. <font face='Courier New'>
  119. <span id='hours'>--</span><span id='tick'>-<span id='minutes'>--</span><span id='stat'>-</span>
  120. </font>
  121. </div>]
 


Thanks,
Darkmage
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Need help with code (21st Feb 08 at 7:34pm UTC)
Who coded that?
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Need help with code (21st Feb 08 at 8:28pm UTC)
I don't know Ive had that for 3 years now, I found it off a website, that was dead, and decided to use it.

I don't understand one bit of it, and I can't find the (24) part so I can't change it to 12.
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Need help with code (23rd Feb 08 at 11:34pm UTC)
bump
Paddy
Full Member
***
Insane Clown

[Avatar]

Posts: 288
Status: Offline
Gender: Male
Location: Buffalo, New York
Age: 35
Joined:  
Reputation: 7%  


pmwwwtwitterskypeaimgtalk
Re: Need help with code (24th Feb 08 at 3:39am UTC)
Code:
 
  1. <SCRIPT LANGUAGE = "JavaScript">
  2. <!-- Begin Script
  3.  
  4. //Display Time of last visit script
  5.  
  6.  
  7. var expDays = 30;
  8. var exp = new Date();
  9. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  10.  
  11. function When(info){
  12. // When
  13. var rightNow = new Date()
  14. var WWHTime = 0;
  15. WWHTime = GetCookie('WWhenH')
  16.  
  17. WWHTime = WWHTime * 1
  18.  
  19. var lastHereFormatting = new Date(WWHTime); // Date-i-fy that number
  20. var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
  21. var lastHereInDateFormat = "" + lastHereFormatting; // Gotta use substring functions
  22. var dayOfWeek = lastHereInDateFormat.substring(0,3)
  23. var dateMonth = lastHereInDateFormat.substring(4,10)
  24. var hours =  lastHereFormatting.getHours()
  25. if(hours > 12){
  26.     hours = hours - 12 + " pm"
  27. }else{
  28.     hours = hours + " am"
  29. }
  30. hours = "" + hours
  31. var year = lastHereFormatting.getYear()
  32. if (year < 1000) year+=1900
  33. var minutes = "" + lastHereFormatting.getMinutes()
  34. if (minutes.substring(0,1) == minutes){
  35. minutes = "0" + minutes
  36. }
  37. var WWHText = dayOfWeek + ", " + dateMonth + " " + year + " at " + hours + ":" + minutes// display
  38.  
  39. SetCookie ("WWhenH", rightNow.getTime(), exp)
  40.  
  41. return WWHText;
  42. }
  43.  
  44. function Count(info){
  45. var psj=0;
  46. // How many times
  47. var WWHCount = GetCookie('WWHCount')
  48. if (WWHCount == null) {
  49. WWHCount = 0;
  50. }
  51. else{
  52. WWHCount++;
  53. }
  54. SetCookie ('WWHCount', WWHCount, exp);
  55.  
  56.  
  57. return WWHCount+1;
  58. }
  59.  
  60.  
  61.  
  62. function set(){
  63. // VisitorName = prompt("Who are you?", "Nada");
  64. // SetCookie ('VisitorName', VisitorName, exp);
  65. SetCookie ('WWHCount', 0, exp);
  66. SetCookie ('WWhenH', 0, exp);
  67. }
  68.  
  69. function getCookieVal (offset) {
  70. var endstr = document.cookie.indexOf (";", offset);
  71. if (endstr == -1)
  72. endstr = document.cookie.length;
  73. return unescape(document.cookie.substring(offset, endstr));
  74. }
  75.  
  76. function GetCookie (name) {
  77. var arg = name + "=";
  78. var alen = arg.length;
  79. var clen = document.cookie.length;
  80. var i = 0;
  81. while (i < clen) {
  82. var j = i + alen;
  83. if (document.cookie.substring(i, j) == arg)
  84. return getCookieVal (j);
  85. i = document.cookie.indexOf(" ", i) + 1;
  86. if (i == 0) break;
  87. }
  88. return null;
  89. }
  90.  
  91. function SetCookie (name, value) {
  92. var argv = SetCookie.arguments;
  93. var argc = SetCookie.arguments.length;
  94. var expires = (argc > 2) ? argv[2] : null;
  95. var path = (argc > 3) ? argv[3] : null;
  96. var domain = (argc > 4) ? argv[4] : null;
  97. var secure = (argc > 5) ? argv[5] : false;
  98. document.cookie = name + "=" + escape (value) +
  99. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  100. ((path == null) ? "" : ("; path=" + path)) +
  101. ((domain == null) ? "" : ("; domain=" + domain)) +
  102. ((secure == true) ? "; secure" : "");
  103. }
  104.  
  105. function DeleteCookie (name) {
  106. var exp = new Date();
  107. exp.setTime (exp.getTime() - 1);
  108. // This cookie is history
  109. var cval = GetCookie (name);
  110. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  111.  
  112. }
  113. // End Script -->
  114. </SCRIPT>
  115. <center><script>
  116. if (Count()==1){
  117. document.write("This is your 1st visit to our page")
  118. When()
  119. }
  120. else if (Count()>1)
  121. document.write("Welcome back. Your last visit was on <b>" + When() +"</B>.")
  122. </script></center>
  123. <div align='center'>
  124. <font face='Courier New'>
  125. <span id='hours'>--</span><span id='tick'>-<span id='minutes'>--</span><span id='stat'>-</span>
  126. </font>
  127. </div>]
  128.  
 


Try that?

~Artemis
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Need help with code (24th Feb 08 at 3:48am UTC)
This is what comes out:
Welcome back. Your last visit was on Sat, Feb 23 2008 at 9 pm:47.

Paddy
Full Member
***
Insane Clown

[Avatar]

Posts: 288
Status: Offline
Gender: Male
Location: Buffalo, New York
Age: 35
Joined:  
Reputation: 7%  


pmwwwtwitterskypeaimgtalk
Re: Need help with code (24th Feb 08 at 4:51am UTC)
oh, hang on...

Code:
 
  1. <SCRIPT LANGUAGE = "JavaScript">
  2. <!-- Begin Script
  3.  
  4. //Display Time of last visit script
  5.  
  6.  
  7. var expDays = 30;
  8. var exp = new Date();
  9. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  10.  
  11. function When(info){
  12. // When
  13. var rightNow = new Date()
  14. var WWHTime = 0;
  15. WWHTime = GetCookie('WWhenH')
  16.  
  17. WWHTime = WWHTime * 1
  18.  
  19. var lastHereFormatting = new Date(WWHTime); // Date-i-fy that number
  20. var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
  21. var lastHereInDateFormat = "" + lastHereFormatting; // Gotta use substring functions
  22. var dayOfWeek = lastHereInDateFormat.substring(0,3)
  23. var dateMonth = lastHereInDateFormat.substring(4,10)
  24. var hours =  lastHereFormatting.getHours()
  25. var meridian = 'am'
  26. if(hours > 12){
  27.     hours = hours - 12
  28.     meridian = 'pm'
  29. }else{
  30.     hours = hours
  31. }
  32. hours = "" + hours
  33. var year = lastHereFormatting.getYear()
  34. if (year < 1000) year+=1900
  35. var minutes = "" + lastHereFormatting.getMinutes()
  36. if (minutes.substring(0,1) == minutes){
  37. minutes = "0" + minutes
  38. }
  39. var WWHText = dayOfWeek + ", " + dateMonth + " " + year + " at " + hours + ":" + minutes + ' ' + meridian// display
  40.  
  41. SetCookie ("WWhenH", rightNow.getTime(), exp)
  42.  
  43. return WWHText;
  44. }
  45.  
  46. function Count(info){
  47. var psj=0;
  48. // How many times
  49. var WWHCount = GetCookie('WWHCount')
  50. if (WWHCount == null) {
  51. WWHCount = 0;
  52. }
  53. else{
  54. WWHCount++;
  55. }
  56. SetCookie ('WWHCount', WWHCount, exp);
  57.  
  58.  
  59. return WWHCount+1;
  60. }
  61.  
  62.  
  63.  
  64. function set(){
  65. // VisitorName = prompt("Who are you?", "Nada");
  66. // SetCookie ('VisitorName', VisitorName, exp);
  67. SetCookie ('WWHCount', 0, exp);
  68. SetCookie ('WWhenH', 0, exp);
  69. }
  70.  
  71. function getCookieVal (offset) {
  72. var endstr = document.cookie.indexOf (";", offset);
  73. if (endstr == -1)
  74. endstr = document.cookie.length;
  75. return unescape(document.cookie.substring(offset, endstr));
  76. }
  77.  
  78. function GetCookie (name) {
  79. var arg = name + "=";
  80. var alen = arg.length;
  81. var clen = document.cookie.length;
  82. var i = 0;
  83. while (i < clen) {
  84. var j = i + alen;
  85. if (document.cookie.substring(i, j) == arg)
  86. return getCookieVal (j);
  87. i = document.cookie.indexOf(" ", i) + 1;
  88. if (i == 0) break;
  89. }
  90. return null;
  91. }
  92.  
  93. function SetCookie (name, value) {
  94. var argv = SetCookie.arguments;
  95. var argc = SetCookie.arguments.length;
  96. var expires = (argc > 2) ? argv[2] : null;
  97. var path = (argc > 3) ? argv[3] : null;
  98. var domain = (argc > 4) ? argv[4] : null;
  99. var secure = (argc > 5) ? argv[5] : false;
  100. document.cookie = name + "=" + escape (value) +
  101. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  102. ((path == null) ? "" : ("; path=" + path)) +
  103. ((domain == null) ? "" : ("; domain=" + domain)) +
  104. ((secure == true) ? "; secure" : "");
  105. }
  106.  
  107. function DeleteCookie (name) {
  108. var exp = new Date();
  109. exp.setTime (exp.getTime() - 1);
  110. // This cookie is history
  111. var cval = GetCookie (name);
  112. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  113.  
  114. }
  115. // End Script -->
  116. </SCRIPT>
  117. <center><script>
  118. if (Count()==1){
  119. document.write("This is your 1st visit to our page")
  120. When()
  121. }
  122. else if (Count()>1)
  123. document.write("Welcome back. Your last visit was on <b>" + When() +"</B>.")
  124. </script></center>
  125. <div align='center'>
  126. <font face='Courier New'>
  127. <span id='hours'>--</span><span id='tick'>-<span id='minutes'>--</span><span id='stat'>-</span>
  128. </font>
  129. </div>]
 


That'll fix you up.

~Artemis
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: Need help with code (24th Feb 08 at 10:23pm UTC)
Thanks it works ^_^
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Need help with code (24th Feb 08 at 10:36pm UTC)
Thanks Arty! {Smile}
 Printable View

All times are GMT+0 :: The current time is 6:57am
Page generated in 1.061 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums