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

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 1, 2025

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

      June 1, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 1, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 1, 2025

      My top 5 must-play PC games for the second half of 2025 — Will they live up to the hype?

      June 1, 2025

      A week of hell with my Windows 11 PC really makes me appreciate the simplicity of Google’s Chromebook laptops

      June 1, 2025

      Elden Ring Nightreign Night Aspect: How to beat Heolstor the Nightlord, the final boss

      June 1, 2025

      New Xbox games launching this week, from June 2 through June 8 — Zenless Zone Zero finally comes to Xbox

      June 1, 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

      Student Record Android App using SQLite

      June 1, 2025
      Recent

      Student Record Android App using SQLite

      June 1, 2025

      When Array uses less memory than Uint8Array (in V8)

      June 1, 2025

      Laravel 12 Starter Kits: Definite Guide Which to Choose

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

      My top 5 must-play PC games for the second half of 2025 — Will they live up to the hype?

      June 1, 2025
      Recent

      My top 5 must-play PC games for the second half of 2025 — Will they live up to the hype?

      June 1, 2025

      A week of hell with my Windows 11 PC really makes me appreciate the simplicity of Google’s Chromebook laptops

      June 1, 2025

      Elden Ring Nightreign Night Aspect: How to beat Heolstor the Nightlord, the final boss

      June 1, 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)

    June 1, 2025
    Tech & Work

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

    June 1, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    CVE-2025-48112 – Karimmughal Cross-site Scripting (XSS) Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Intel’s latest AI laptop processor keeps up with AMD, but it forgot something important

    News & Updates

    How to Use AI to Build a WordPress Related Posts Plugin

    Learning Resources

    The Ant Monster

    Artificial Intelligence

    Highlights

    Development

    Ransomware Extortion Drops to $813.5M in 2024, Down from $1.25B in 2023

    February 6, 2025

    Ransomware attacks netted cybercrime groups a total of $813.5 million in 2024, a decline from…

    Mapping the misuse of generative AI

    May 13, 2025

    The super-secure SSD is not just hacker-proof, but also water and dust resistant

    February 6, 2025

    Migrate Amazon RDS for Oracle BLOB column data to Amazon S3

    August 29, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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