Archive for November, 2021

                                           

How to move or shift date by n number of days

shift date by n number of days

Here is a quick way to shift a day by n number of days, by adding those days, and adjusting the date. In the process, we will pay attention to moving the days into another month or year if we have to. Of course, this depends on the few date manipulation methods we saw last […]

                     

Working with Dates and Time in JavaScript

Working with dates and time is very scary, I admit. Most of the time I retreat and find a library that can handle the details for me and avoid this topic at all costs. Besides libraries, JavaScript has a built-in class called Date which represents a point in time. And, if we like, we can […]

                                           

Constructor Property Promotion in PHP8

Constructor property promotion in PHP8 code example

Constructor property promotion in PHP8 is one of the new features which make our code less verbose and less error-prone. Similar to the match expressions which I wrote about last week. Before we see what constructor property promotions in PHP8 look like, let’s take a look at a typical class declaration. As you can see, […]

                     

Match Expressions in PHP8 over Switch statement

Match expressions in PHP8

Match expressions in PHP8 are among the many new features that encourage good standards when writing code. They might seem just another short-hand syntax. However, match expressions effectively replace switch statements and make our code cleaner, readable, and less prone to errors.