All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Use the Constant Generator iota in Golang

Working with Constants and iota in Go. The Constant Generator iota Here’s an example from the time package, which defines named constants of type Weekday for the days of the week, starting with zero for Sunday. Types of this kind are often called en...
pooriabt

How to Calculate Number of Days Between Two Given Dates in Python

In Python, using the timedelta object is the easiest way to calculate number of days between two given dates. Using timedelta If you have two date objects, you can just subtract them, which computes a timedelta object. In this program, we will cal...
Unused

How to Get the Day of Week Given a Date in Python

In Python, there are 2 ways to get the day of week given a date. Using weekday Method The weekday() method returns the day of the week as an integer, where Monday is 0 and Sunday is 6. The following example should cover whatever you are trying to ...
Sambhav Khandelwal

How to Subtract a Day from a Date in Python

In Python, using the timedelta object is the easiest way to subtract a day from a date. Using timedelta Object A timedelta object represents a duration, the difference between two dates or times. See the following example: #!/usr/bin/python3 #...
Sambhav Khandelwal

How to Get the Current Time in Python

In Python, there are 2 ways to get the current time. Using datetime Module The datetime module supplies classes for manipulating dates and times. See the following example: #!/usr/bin/python3 # -*- coding: utf8 -*- # Import module import datet...
Patcher56

How to get the first and last day of the current month in Go

In Golang, there are two ways to get the start and end date of the current month.Using time.AddDate Function AddDate returns the time corresponding to adding the given number of years, months, and days to t. For example, package main import ( "fm...
Tomoki

How to format a date or time in Go

In Golang, there are two ways to format the time.The layout string Go doesn’t use yyyy-mm-dd layout to format a time. Instead, you format a special layout parameter. 2006-01-02 15:04:05.999999999 -0700 MST package main import ( "fmt" "tim...
aweis

How to use the find command in Linux

search for files and directories based on their permissions, type, date, ownership, size, and more. find is a command-line utility that locates files based on some user-specified criteria and either prints the pathname of each matched object or, if ...

How to install date-fns

Modern JavaScript date utility library.--pname-- provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js. --pname-- is like lodash for dates. It has 140+ functions for all occasions...

How to install Moment.js

A JavaScript date library for parsing, validating, manipulating, and formatting dates.--pname-- was designed to work both in the browser and in Node.js. All code should work in both of these environments, and all unit tests are run in both of these e...