Tag:Hours

  • JS implementation countdown

    Time:2021-9-1

    Many games are used to countdown, such as annual meeting, birthday, date… Nonsense, not much code design sketch: index.html <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <title>Document</title> <style> body{ background-color: #2a3852; } #box { display: flex; justify-content: center; align-items: center; flex-direction: column; margin-top: 300px; } #box h1 { letter-spacing: 3px; font-weight: […]

  • Python time difference calculation

    Time:2021-8-4

    Method 1: the time to be calculated is a fixed value import datetime c=”2020-12-08 11:30:00″ d1=datetime.datetime.strptime(str(c),”%Y-%m-%d %H:%M:%S”) d3 = d1 – datetime.timedelta(seconds=900) d3.ctime() Method 2: use the current time for calculation Datetime can view: days, hours, weekday (); Timedelta can view: days, seconds, etc. import datetime d1 = datetime.datetime.now() d3 = d1 + datetime.timedelta(hours=10) d3.ctime()

  • Description of the relationship among Swift’s date, dateformatter, datecomponents and locale

    Time:2021-4-6

    Description of the relationship among Swift’s date, dateformatter, datecomponents and locale preface It’s important for processing time to understand the relationship between these classes and what they do Class name explain be careful Date It’s just a data that represents the time. It only represents the time node, just like the timestamp DateFormatter It formats […]

  • Vue ~ using Axios to download Excel files

    Time:2021-2-19

    The export or download function on the front-end Vue page is generally to call an interface of the back-end, which generates the stream information of Excel and word files and returns it to Vue. Then Vue builds the download action, which is sorted and encapsulated here to facilitate reuse in the future. Encapsulating a download […]

  • JavaScript returns the current time, minute and second

    Time:2021-1-31

    requirement: Encapsulates a function that returns the current time, minute and secondFormat 08:08:08 Code implementation: function getTimer() { var time = new Date(); var h = time.getHours(); h = h < 10 ? ‘0’ + h : h; var m = time.getMinutes(); m = m < 10 ? ‘0’ + m : m; var s […]

  • JavaScript displays the remaining time function

    Time:2021-1-30

    Realization idea: The input time minus the current time is the remaining time, but you can’t subtract the time, minutes and seconds. For example, if you subtract 25 minutes from 05 minutes, the result will be negative. You can use ittime stampTo do this, subtract the total number of milliseconds of the current time from […]

  • JS to get the current time (yesterday, today, tomorrow)

    Time:2021-1-24

    1. Time format 1 // yesterday’s time 2 var day1 = new Date(); 3 day1.setTime(day1.getTime()-24*60*60*1000); 4 var s1 = day1.getFullYear()+”-” + (day1.getMonth()+1) + “-” + day1.getDate(); 5 // today’s time 6 var day2 = new Date(); 7 day2.setTime(day2.getTime()); 8 var s2 = day2.getFullYear()+”-” + (day2.getMonth()+1) + “-” + day2.getDate(); 9 // tomorrow’s time 10 var […]

  • Java output the current date of the system

    Time:2021-1-14

    Copy codeThe code is as follows: package test.remote.tools.combine; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class TestOutDate { public static void main(String[] args) { //method 1 Calendar nowtime = new GregorianCalendar(); String strDateTime=”[“+String.format(“%04d”, nowtime.get(Calendar.YEAR))+”/”+ String.format(“%02d”, nowtime.get(Calendar.MONTH))+”/” + String.format(“%02d”, nowtime.get(Calendar.DATE))+” ” + String.format(“%02d”, nowtime.get(Calendar.HOUR))+”:” + String.format(“%02d”, nowtime.get(Calendar.MINUTE))+”:” + String.format(“%02d”, nowtime.get(Calendar.SECOND))+”.” + String.format(“%03d”, nowtime.get(Calendar.MILLISECOND))+”]”; System.out.println(strDateTime); […]

  • Using native JS to write greetings according to time

    Time:2021-1-3

    Step conception 1) You need to use date built-in objects,2) Get system hours,3) Using the multi branch statement to judge,4) The content of greetings is modified accordingly.   //1. Get elements var div = document.querySelector(‘div’); //2. Get the current hours var nowTime = new Date(); var h = nowTime.getHours(); //3. Judge the hours and change […]

  • JS gets the current time and refreshes it in real time

    Time:2021-1-2

    design sketch <!DOCTYPE html> <html> <head> <meta charset=”{CHARSET}” /> < title > JS gets the current time and refreshes it in real time <script> //Page load call window.onload = function() { //Refresh time every 1 second setInterval(“NowTime()”, 1000); }; function NowTime() { //Date of acquisition var time = new Date(); var year = time.getFullYear(); var month = […]

  • JS date type method collection

    Time:2020-7-15

    Date.parse (); // receives a string parameter representing the date, and then attempts to return the number of milliseconds of the corresponding date based on this string Date.UTC (); // returns the number of milliseconds representing the date, but it is different from Date.parse () use different information when building values Date.now (); // returns […]

  • JS date function

    Time:2020-3-28

    JS date function   1. Creation time var mydate = new date(); 2. Get the current year mydate. Getyear(); (2 digits) 3. Get the complete year mydate. Getfullyear(); (4 digits) 4. Get the month mydate. Getmonth(); (0-november, 0 is January) 5. Get the current date mydate. Getdate(); (1-31) 6. Get the current time mydate. Gettime(); […]