SoFunction
Updated on 2025-04-07

JavaScript with only 2 lines of code displays date and time effects in the specified format

JavaScript with only 2 lines of code displays date and time effects in the specified format

Updated: September 21, 2011 00:27:19 Author:
I have spent a lot of time solving this problem, mainly because the code found on the Internet is either very tedious, or it cannot be general or the format can only be fixed a few, so I specifically studied this problem and finally optimized it to only have 2 lines of code, which is very simple.
I studied Blue Ideal for N years and published my original works for the first time today. Because I spent a lot of time solving this problem, the code found on the Internet was either very tedious, or it could not be general or the format could only be fixed a few, so I specifically studied this problem and finally optimized it to only 2 lines of code, which was very simple. The main thing is to use JSON, regular and eval functions. If you have any questions, please correct them.
Thanks to zhanyuzai for the optimization. After testing the 2 lines of code, no problems were found. It has been updated now.

[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
  • Date and time

Related Articles

  • A simple timer written in javascript

    Today I need to use a timer to make something. I have seen several electronic clocks before, and then I think about setting up an electronic timer.
    2009-07-07
  • Compatibility writing of IE and javascript getyears under Firefox

    Solution to the inconsistent date of javascript getyear under IE and Firefox
    2007-12-12
  • A better written JavaScript date selection control

    What seems to be a little bit flawed is that after testing, it seems that it only supports MS IE browser, and there are some problems with the support for Opera and FireFox browsers.
    2009-02-02
  • js calculates the time of the past

    Calculate how long the js code has been in the past. It is also good to add a js code and automatically switch to the current focus. You can do it manually.
    2008-02-02
  • JS calendar control (blue)

    Super beautiful JS calendar control, the code is a bit complicated.
    2010-03-03
  • In JavaScript, the counter is automatically increased by 1 per second

    In JavaScript, the counter automatically adds 1 per second...
    2007-08-08
  • JavaScript code to compare time sizes

    Today I searched for JS on Google today and compared the time and very few can be used. The js static function() parameters have very strict requirements. Otherwise, the conversion will fail.
    2010-04-04
  • A simple calendar code (For: FF1+ IE5+ Opr7+) test

    A simple calendar code (For: FF1+ IE5+ Opr7+) test...
    2007-03-03
  • A date drop-down menu js implementation code

    The date drop-down menu effect code implemented with js. Using js is mainly for easy control and does not require many menus to be entered.
    2012-10-10
  • Javascript date object Date extension method

    Date object extension, including common Chinese date format analysis, addition and subtraction operations, date difference, weekly operations and quarterly operations.
    2009-05-05

Latest Comments