How to Get Yesterday’s Date in JavaScript (With Examples)

Occasionally you may want to calculate yesterday’s date using JavaScript. Here are three methods you can use to do so.

Method 1: Using Today’s Date 

Using this method, we define today’s date, then subtract one day from it:

var today = new Date();


console.log(today.toDateString()); // Wed Sep 30 2020

Method 2: Using Milliseconds

Using this method, we simply subtract 86,400,000 milliseconds (the number of seconds in one day) from today’s date:

var yesterday = new Date( - 864e5);

console.log(yesterday.toDateString()); // Wed Sep 30 2020

Method 3: Using Moment.js

Using this method, we can simply use the subtract() function from the Moment.js JavaScript library:

moment().subtract(1, 'days'); // Wed Sep 30 2020
Life is About Finding Fulfilling Work, Not Saving Up Enough Money to Never Work Again

Life is About Finding Fulfilling Work, Not Saving Up Enough Money to Never Work Again

When I first discovered the concept of early retirement, I thought it was the solution to lasting happiness and bliss.

The idea is simple: save up enough money over the course of 10 to 15 years so that you can live purely off investment returns/dividends, and never need to work again.

I hated the idea of working 40 hours per week in a cube for 40 years doing work I found pointless, so stacking up enough savings to  never need a traditional office job again seemed like a great idea.

The more I researched this idea, though, the more surprising results I found. As I consumed books, articles, podcasts, and videos by people who had actually quit the rat race at a young age, I noticed a trend: each of these people experienced a void in their life.

The same pattern kept popping up: people would achieve the financial means to quit their day job, then travel for a couple weeks or months…then get bored.

The reason is because humans adapt quickly. The most obvious example of this is hedonic adaptation: as one increases their income, they tend to inflate their lifestyle more and more, yet remain roughly at the same happiness level.

This is because everything becomes normal over time. The new house, watch, phone, and car all become quite ordinary after a while. Even constant travel and leisure becomes mundane quicker than one might think.

The Solution

The solution, in nearly every case, was for these people to pursue work they found fulfilling – starting a business, an agency, a blog, a podcast, building a product, etc. – that used their unique skillset to help others and ironically help them earn income at the same time.

When you have something to work on, to build, and to create, you suddenly kill the void. You have a reason to get out of bed each morning and do work that you find meaningful and that makes a positive impact on other people.

It turns out that work is also correlated with longevity. In a fascinating study on retirement, researchers found that retirees were 51% more likely to have died than their counterparts who continued working, and a 5-year increase in the retirement age was linked with a 10% decrease in all-cause mortality.

As anecdotal evidence, just look at anyone in their 80s or 90s who continues to work full-time like Warren Buffett, Charlie Munger, or Jiro Ono – it’s not about the money for them, it’s about doing work they love.

If you’ve never heard of Jiro Ono, I encourage you to watch the Netflix documentary “Jiro Dreams of Sushi.” Check out the trailer below:

Doing Work on Your Terms

The path to a good life doesn’t involve quitting work entirely, but rather finding fulfilling work that you can do on your terms. 

Personally I don’t hate the actual work I do as a data scientist at my day job. I do, however, hate the environment that this work is wrapped in.

I don’t enjoy commuting, attending pointless meetings, going through performance reviews, dealing with office politics, or being expected to sit in a certain spot in a certain building for eight hours each day.

If I was instead able to work on data analytics and visualizations for projects I find meaningful and during hours that I choose, I’d be much happier.

Related: I enjoyed statistics so much that I decided to start my own site Statology that teaches students various statistics concepts. Because this was a project that I decided to undertake on my own time and had no restrictions or deadlines, it was extremely fun to build despite the fact that it took several months.

I believe many people share this sentiment. It’s not the work we hate, it’s the environment that the work is wrapped in.

In general, the 9-5 schedule is outdated and unnatural. Office environments are not conducive to most types of work. From many people I’ve talked to, a common trend I notice is that most people are actually happy to work several hours per day, but only on work they find meaningful and only on a schedule that is flexible.

The Role of Financial Independence

Of course, the best way to obtain the freedom necessary to do work you enjoy on your own terms is to attain some level of financial independence.

This is the path I’m currently on myself. I’ve managed to save about $120k over the past 2.5 years.

My original goal when I first started was to save $1 million and never work again. Now, my goal is to save $250k – $350k and build up my income streams outside of my day job to a point where they consistently cover my monthly expenses.

In the last few months, these income streams have covered 50-75% of my monthly expenses, so I’m getting close to hitting this target.

For me, meaningful work is blogging and creating websites. Once I do quit my day job, though, I suspect that I’ll discover more work I enjoy doing once I have complete freedom over my time to experiment with different types of work.

I suspect that this is an additional benefit of not having a traditional job – you actually have space to experiment and tinker with different project ideas, which could turn into unexpected income streams.

Finding Fulfilling Work

If you’re on the path to financial independence, I encourage you to start thinking about finding fulfilling work rather than attempting to hit some net worth number and never work again.

More than likely, once you start experimenting with different types of work, you’ll find that you can earn at least some income doing something you enjoy.

This means that you could actually quit your day job before you’re completely financially independent since you won’t rely completely on investment returns and dividends to support your lifestyle.

I’ll leave you with three quotes from three incredible thinkers that emphasize the role that work plays in a meaningful life:

“We act as though comfort and luxury are the chief requirements of life, when all that we need to make us happy is something to be enthusiastic about”Albert Einstein


“What humans need and want isn’t a complete release of tension and responsibility, but the pursuit of a worthwhile goal that they chose freely.” – Viktor Frankl


“Fall in love with some activity, and do it! Nobody ever figures out what life is all about, and it doesn’t matter. Explore the world. Nearly everything is really interesting if you go into it deeply enough.”Richard Feynman

The Secret to Becoming Prolific

The Secret to Becoming Prolific

I’m a morning person.

I love waking up early and getting a jumpstart on my day while most of the world is still sleeping.

My morning routine is simple: I wake up around 6 AM, take a freezing cold shower, drink a large glass of water, brew a cup of coffee, then sit down at my dining room table.

I place one of my succulent plants on the table next to me, open my laptop, put my headphones in, then turn on some background noise from Noisli.

I spend the next two to three hours writing a blog post for either or

Related: Why plants on workdesks boost creativity

Once I’m finished, I hit “publish”, tweet out the article, then move on with my day. If it’s a weekday, I get ready for work and head out the door. If it’s a weekend, I typically head to the gym afterwards. 

The Secret to Becoming Prolific

One common question I receive from readers is: How are you able to produce articles so consistently?

The simple answer is that I follow my energy. When my energy is high, I choose to write. When my energy is low, I choose to be lazy. 

For me, my energy is highest in the mornings. It’s when I’m able to concentrate deeply, sit without distractions, and be highly productive. As the day wanes on, my energy drops lower and lower.

In the evening, I’m completely unproductive. I might tweet out a couple links to articles or respond to emails, but I don’t do any deep work.

Instead, I’ll have dinner, read a book, play some video games, watch Netflix (I’m currently on season 2 of Happy Valley – highly recommend), or hang out with my girlfriend. 

Anyone can write one article per day for a week, but not many people are able to write one article per day for months or even years.

The secret to becoming prolific over a long stretch of time is to give yourself opportunities to rest and recharge frequently. For me, I let myself rest every evening. This helps me avoid burnout.

In Deep Work, Cal Newport shares how he has become a prolific professor, author, and computer programmer:

“I build my days around a core of carefully chosen deep work, with the shallow activities I absolutely cannot avoid batched into smaller bursts at the peripheries of my schedule. Three to four hours a day, five days a week, of uninterrupted and carefully directed concentration, it turns out, can produce a lot of valuable output.”

He doesn’t work 16 hours a day. He finds time to be highly productive for several hours, five days a week. By committing to this schedule for years, he has been able to churn out an incredible amount of high quality books and academic papers.

The Two Enemies of Becoming Prolific

There are two primary things that will kill your ability to be prolific: comparison and short-term thinking.

No matter what field you’re in, there will always be someone who is better than you, who writes more concisely than you, who earns more money than you, who has more followers than you.

If you spend too much time dwelling on your shortcomings relative to these people, you’re likely to become discouraged and quit.

This is why it’s so important to avoid comparing your progress to others. One essay I frequently refer to that helps me avoid the temptation to compare myself to others comes from Seth Godin:

Without a doubt, there’s someone taller than you, faster than you, cuter than you.

We don’t have to look very far to find someone who is better paid, more respected and getting more than his fair share of credit.

And social media: Of course there are people with more followers, more likes and more of just about anything you’d like to measure.

So what?

What is the comparison for?

Is your job to be the most at a thing? Perhaps if you play baseball, the goal is to have the highest on-base percentage. But it’s probably more likely that you should focus on the entire team winning the game.

Just because a thing can be noticed, or compared, or fretted over doesn’t mean it’s important, or even relevant.

Better, I think, to decide what’s important, what needs to change, what’s worth accomplishing. And then ignore all comparisons that don’t relate. The most important comparison, in fact, is comparing your work to what you’re capable of.

Sure, compare. But compare the things that matter to the journey you’re on. The rest is noise.

The second enemy of becoming prolific is short-term thinking. So many people start projects, blogs, or businesses, and expect to see results within the first two to three months. Unfortunately, results are delayed in virtually every field.

The effort you put in now won’t culminate in visible results until several months or even years from now.

This is why it’s so important to embrace long-term thinking. Give yourself years to succeed, not months.

One quote I often think about comes from Steven Pressfield in Tribe of Mentors:

“I’m 74. Believe me, you’ve got all the time in the world. You’ve got ten lifetimes ahead of you. Don’t worry about your friends “beating” you or “getting somewhere” ahead of you. Get out into the real dirt world and start failing.”

Don’t worry about proving yourself or about finding success as quick as possible. Just get moving. 

As James Clear once said, “Rome wasn’t built in a day, but they were laying bricks every day.”

Give yourself the advantage of a long-term perspective. Don’t stress about finding success immediately. Just lay one brick each day.


There are three steps you can take to become prolific:

  • Identify when your energy is highest each day. Use that time to be highly productive.
  • Avoid burnout by allowing yourself to rest each day.
  • Avoid quitting by resisting comparison and short-term thinking.