SShortSingh.
Back to feed

Unix Timestamps Explained: Common Developer Mistakes and How to Avoid Them

0
·2 views

Unix timestamps count the seconds (or milliseconds) elapsed since January 1, 1970 at 00:00:00 UTC, a reference point known as the Unix epoch. One of the most frequent developer errors involves confusing second-based timestamps (10 digits) with millisecond-based ones (13 digits), which can cause dates to display incorrectly by decades. JavaScript's Date API expects milliseconds, so passing a seconds-based timestamp directly without multiplying by 1000 will produce a wrong date near January 1970. Importantly, a Unix timestamp carries no time zone information — it represents a single universal instant, and only its human-readable formatting changes across time zones. Developers are advised to always store timestamps in UTC, avoid manual time-zone offsets, and account for daylight saving time when converting timestamps to local representations.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How Pixel Budgeting Prevents PDF-to-Image Timeouts in Property Management Apps

Developers handling PDF-to-image conversions in property management systems often misdiagnose timeouts as broken files, when the real cause is an unbudgeted rendering workload. Page geometry and total output pixel count — calculated using page dimensions, DPI, and page count — should be assessed before any conversion job is scheduled. Doubling the DPI quadruples output pixels due to a square-law effect, meaning a 40-page lease at 300 DPI represents a far heavier workload than it appears. Privacy and completeness rules are equally critical: no unredacted page should reach preview storage, and a preview should only be marked ready once every admitted page has been successfully rendered and redacted. Teams are advised to set explicit policy limits on pages, pixels, and in-flight memory, routing oversized requests to asynchronous queues rather than blocking interactive workers.

0
ProgrammingDEV Community ·

Developer automates full Kubernetes HA cluster setup on a single KVM host

A developer frustrated by repeatedly rebuilding a homelab Kubernetes cluster by hand created a shell script that automates the entire process with a single command. The script provisions six VMs on one KVM host, configures HAProxy as a load balancer, initializes a three-node control-plane cluster using kubeadm with stacked etcd, and adds two worker nodes with ingress-nginx. It uses Rocky Linux 9 cloud images with cloud-init to avoid manual OS installation, and runs node preparation steps in parallel to cut setup time to roughly 10–20 minutes. The script is divided into idempotent stages, so a failed run can be resumed from the point of failure rather than restarted from scratch. The project is aimed at homelab enthusiasts and those studying for the Certified Kubernetes Administrator exam, and has been published with a full README.

0
ProgrammingDEV Community ·

Go developer builds ginboot to cut boilerplate in Gin-based HTTP services

A Go developer created ginboot, a lightweight framework layer built on top of the popular Gin HTTP library, to eliminate repetitive handler code across services. The tool addresses recurring patterns such as request binding, error handling, and CRUD repository setup that developers typically rewrite for every new Gin project. In ginboot, handlers return a typed value and an error instead of manually writing JSON responses, with the framework automatically handling binding failures and error-to-status-code mapping at route registration time. It also provides a generic MongoDB repository, structured API error types, and opinionated defaults for config loading and health endpoints. The project is positioned not as a new HTTP stack but as a set of conventions that preserve full access to the underlying Gin context and ecosystem.

0
ProgrammingDEV Community ·

GitHub Copilot App vs JetBrains Air: A Java Dev Compares Agentic IDEs

A Java developer with a long history of using IntelliJ tested two AI-first IDEs — GitHub Copilot App and JetBrains Air — to evaluate their agentic coding capabilities. The GitHub Copilot App impressed by autonomously resolving a Java toolchain certificate error and opening Swagger docs directly within the IDE, reducing manual setup steps. However, its use of git worktrees made it difficult to manually browse or edit the codebase alongside the tool, forcing the developer to keep IntelliJ open separately. JetBrains Air, a new offering from the makers of IntelliJ, places the AI prompt front and center with a familiar interface and supports multiple AI providers including Claude and Gemini. The developer found Air's cleaner UI appealing, though the full comparison between the two tools was still underway at the time of writing.