Hey everyone, I'm wondering if someone can help me out. For my ecommerce site I would like to add a countdown timer. On amazon.com they display the following: Want it delivered Tuesday, January 9? Order it in the next 35 hours and 37 minutes, and choose One-Day Shipping at checkout. See details I found this thread here: http://forums.digitalpoint.com/showthread.php?t=23934&highlight=countdown But it doesn't do exactly what I need. The codes on that page will display a countdown... but I have more variables. The biggest issue comes down to days of the week. For example... if I want people to order by 9 AM to get their orders the next day... I can't have my site show a user at 8 am on saturday that if he orders within 1 hour he'll get it on Sunday (UPS doesn't ship or delivery on Saturday or Sunday). So... I would need to set some variable where if it's Saturday at 8 and a users views a page it would change to: Want it delivered next Tuesday? Order it in the next 1 hours, and choose One-Day Shipping at checkout. See details If they are on the site Sunday at 8 AM it will say the same thing. Same as on Monday. But on Tuesday it would say: Want it delivered on Wednesday? Order it in the next 1 hours, and choose One-Day Shipping at checkout. See details Make sense? Can anyone help me out or point me in the right direction? I'm not an ASP programmer but if I'm given a starting point I can play around with the code for a while to hopefully get it working the way I want
i'd take the code you have currently, and post it. Then ask if anyone can suggest a snippet to include to account for holidays and weekends. I think some if statements using some of the ASP date and time functions would work well.
http://www.411asp.net/func/content?tree=411asp/tutorial/howto/datetime&id=6155910 may also be a good starting point for .net... Or for the old school methods.. http://www.codefixer.com/tutorials/date_time_greetings.asp
Here's the code I currently have. This works by telling the user what day their order will arrive. But... what I can't figure out yet is how to get a countdown timer integrated. I want to replace my "next ** hours and ** minutes" with "next 4 hours and 15 minutes" and similar. Any ideas would really be appreciated. <% Dim h, DayOfTheWeekName 'create variable that will store the hour h=hour(now) 'pass in the date and time to the hour function as a parameter DayOfTheWeek = Weekday(Date) %> <% If DayOfTheWeekName = "1" OR "6" OR "7" Then response.write "Want your order delivered by Tuesday?" response.write "Order in the next ** hours and ** minutes and choose next day air as your shipping method" Else If DayOfTheWeekName = "2" Then response.write "Want your order delivered by Wednesday?" response.write "Order in the next ** hours and ** minutes and choose next day air as your shipping method" Else If DayOfTheWeekName = "3" Then response.write "Want your order delivered by Thursday?" response.write "Order in the next ** hours and ** minutes and choose next day air as your shipping method" Else If DayOfTheWeekName = "4" Then response.write "Want your order delivered by Friday?" response.write "Order in the next ** hours and ** minutes and choose next day air as your shipping method" Else If DayOfTheWeekName = "5" Then response.write "Want your order delivered by Monday?" response.write "Order in the next ** hours and ** minutes and choose next day air as your shipping method" End If End If End If End If End If %> Code (markup):
As for the countdown timer... this is as far as I've gotten so far: <% response.write(dateDiff("h",now(),date+1)) & " hours and " & dateDiff("m",now(),date+1) & " Minutes " %> Code (markup): That counts down the hours until tomorrow... but I can't get the minutes working. The problem is I don't want the minutes from now until tomorrow... I want the hours from now and then tomorrow... and then I want the minutes left over to be displayed. I can write if/else statements to determine which date from now should be displayed (date+1, date+2) and so on. I just need to figure out how to countdown the minutes remaining after hours are used. Once I can get that working, I think everything else will fall into place with a bunch of if/else statements. So... can someone help me with the minutes thing?
I have the minutes working now... but it's displaying total minutes from now until tomorrow. For example... if it's 8 AM today, my code is showing 960 minutes. But... I need that code to show 0 minutes (since we're on the hour exactly there are no minutes to display). I think the easiest solution is to do a countdown till the next hour. So if it's 8:30 AM, the script will do 60 minutes minus 30 minutes and the result is the minutes left. How can I do that? <% response.write(dateDiff("h",now(),date+1)) & " hours and " & dateDiff("m",Time(),date+1) & " Minutes " %> Code (markup):
I've not been awake long so... <% myminutesvar = dateDiff("m",Time(),date+1) myhours = myminutesvar\60 theminutesexact = formatnumber(((myminutesvar/60)-myhours),2) response.write(myhours) & " hours and " & theminutesexact & " Minutes " %> Is that more what you mean?