Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 31, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 31, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 31, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 31, 2025

      How to install SteamOS on ROG Ally and Legion Go Windows gaming handhelds

      May 31, 2025

      Xbox Game Pass just had its strongest content quarter ever, but can we expect this level of quality forever?

      May 31, 2025

      Gaming on a dual-screen laptop? I tried it with Lenovo’s new Yoga Book 9i for 2025 — Here’s what happened

      May 31, 2025

      We got Markdown in Notepad before GTA VI

      May 31, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Oracle Fusion new Product Management Landing Page and AI (25B)

      May 31, 2025
      Recent

      Oracle Fusion new Product Management Landing Page and AI (25B)

      May 31, 2025

      Filament Is Now Running Natively on Mobile

      May 31, 2025

      How Remix is shaking things up

      May 30, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      How to install SteamOS on ROG Ally and Legion Go Windows gaming handhelds

      May 31, 2025
      Recent

      How to install SteamOS on ROG Ally and Legion Go Windows gaming handhelds

      May 31, 2025

      Xbox Game Pass just had its strongest content quarter ever, but can we expect this level of quality forever?

      May 31, 2025

      Gaming on a dual-screen laptop? I tried it with Lenovo’s new Yoga Book 9i for 2025 — Here’s what happened

      May 31, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Tech & Work»CodeSOD: One Month

    CodeSOD: One Month

    January 7, 2025

    Joseph sends us a tried and true classic: bad date handling code, in JavaScript. We’ve all seen so much bad date handling code that it takes something special to make me do the “confused dog” head tilt.

    		var months=new Array(13);
    		months[1]='January';
    		months[2]='February';
    		months[3]='March';
    		months[4]='April';
    		months[5]='May';
    		months[6]='June';
    		months[7]='July';
    		months[8]='August';
    		months[9]='September';
    		months[10]='October';
    		months[11]='November';
    		months[12]='December';
    		var time=new Date();
    		var lmonth=months[time.getMonth() + 1];
    		var date=time.getDate();
    		var year=time.getFullYear();
    		document.write(lmonth + ' ');
    		document.write(date + ', ' + year);
    

    We create a 13 element array to hold our twelve months, because we can’t handle it being zero indexed. This array is going to be our lookup table for month names, so I almost forgive making it one-indexed- January is month 1, normally.

    Almost. Because not only is that stupid, the getMonth() function on a date returns the month as a zero-indexed number. January is month 0. So they need to add one to the result of getMonth for their lookup table to work, and it’s just so dumb.

    Then of course, be output this all using document.write, so we just know it’s terrible JavaScript, all the way around.

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    news
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleSkywings Marketing: Premier SEO Company in Ghaziabad
    Next Article How to Enable Full-Width Layouts in Optimizely Commerce (Spire)

    Related Posts

    Tech & Work

    Sunshine And March Vibes (2025 Wallpapers Edition)

    May 31, 2025
    Tech & Work

    The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

    May 31, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Top 10 Red Flags Designers Should Watch for in an Offer Letter

    Web Development

    How to Successfully Market Your React Native App After Launch📣

    Web Development

    GameSir Super Nova review: I would expect to pay much more for this controller and its Hall Effect sticks

    News & Updates

    DeepSeek Unpacked: Security, Innovation, and What’s Next

    Tech & Work

    Highlights

    Artificial Intelligence

    New training approach could help AI agents perform better in uncertain conditions

    January 29, 2025

    A home robot trained to perform household tasks in a factory may fail to effectively…

    BEAL: A Bayesian Deep Active Learning Method for Efficient Deep Multi-Label Text Classification

    November 17, 2024

    This fun mobile action RPG from Netflix Games isn’t coming to PC yet — but it might be in the future

    June 18, 2024
    Model customization, RAG, or both: A case study with Amazon Nova

    Model customization, RAG, or both: A case study with Amazon Nova

    April 10, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.