This article describes the method of implementing flash sale countdown with C# combined with JavaScript. Share it for your reference. The details are as follows:
I have recently done a flash sale event and need to use the countdown. Requires a countdown to start every Wednesday at 10:00 am
private string Dtime() { byte tempB = (byte); byte dayByte = (byte); DateTime wednesdayNow = (dayByte - tempB); //This Wednesday DateTime returnTime = new DateTime (); if ( < ) { //The current week is less than this Wednesday Get this Wednesday returnTime = new DateTime(,,,10,0,0); } else { //The current week is greater than this Wednesday Get next Wednesday DateTime nextWednesday = (7);//Next Wednesday returnTime = new DateTime(,,,10,0,0); } return () }
This method can get the time of every Wednesday and then count down the time with js
$(document).ready(function() { $('body').everyTime('1s', function() { var nowDate = new Date(); var endDate = new Date($("#sp_next").html().replace(//-/g, "//")); //This time is the time returned by the previous method var timeold = () - (); var sectimeold = timeold / 1000 var secondsold = (sectimeold); var msPerDay = 24 * 60 * 60 * 1000 var e_daysold = timeold / msPerDay var daysold = (e_daysold); var e_hrsold = (e_daysold - daysold) * 24 + (daysold * 24); var hrsold = (e_hrsold); var e_minsold = (e_hrsold - hrsold) * 60; var minsold = ((e_hrsold - hrsold) * 60); var seconds = ((e_minsold - minsold) * 60); if (hrsold > 0 && hrsold < 10) { hrsold = "0" + hrsold; } if (minsold < 10) { minsold = "0" + minsold; } if (seconds < 10) { seconds = "0" + seconds; } if (hrsold < 0) { $(".seckill_time").html("0"); $(".seckill_minute").html("0"); $(".seckill_second").html("0"); } else { $(".seckill_time").html("").html(hrsold); $(".seckill_minute").html("").html(minsold); $(".seckill_second").html("").html(seconds); } }); });
I hope this article will be helpful to everyone's C# programming.