You've heard of the 9 to 5, but have you ever heard of the 996?
The 996 refers to working 6 days a week from 9 am to 9 pm. Believe it or not, some developers endure such a routine, but just how common is it?
Does working as a software developer require a lot of overtime? Working overtime developing software is generally more prevalent than other industries, but this is thanks in part to certain situations which are sometimes avoidable. Nowadays, more and more companies are advocating an improvement to work efficiency in place of an overtime culture.
It's important not to generalize, as, on the one hand, roles in the industry that do require an additional commitment may carry enhanced salary and job prospects. Some people don't mind working extra hours, especially if it helps contribute to a cause they believe in (such as a startup succeeding) or if the advantages make it worth their while (three free meals a day, for instance).
As a job seeker operating in an industry with a lot of demand. The impetus is on you to do your research into a company and sign the most suitable contract. Some companies will compensate you for your overtime and others will give you additional working flexibility/reward you with more holidays in return.
So what are the situations that most impact a developer's overtime?
Different periods differ in their intensity
Software projects consist of a clear goal or purpose and have a set number of resources and budget. More importantly still, they must be turned around within a specific time frame.
This time dimension is arguably the trickiest aspect of the project. It can be difficult to produce a precise estimation considering everything that could go wrong, from client change requests to an unexpected bug.
It shouldn't surprise, therefore, that the periods where developers are doing the most overtime is when a deadline is due to be met, and all the team needs to put in the extra effort to achieve their collective goal.
The truth is that some developers choose not to go home.
I am guilty of this myself, in the pursuit of a sense of accomplishment for the day, I will stubbornly hang around until I feel like it's "job done".
This is particularly true if there is a problem to be solved that I've procrastinated on.
Needless to say, this can be counterproductive. Tesla CEO Elon Musk very famously said that he would work 120-hour weeks.
"There were times when, some weeks ... I haven’t counted exactly, but I would just sort of sleep for a few hours, work, sleep for a few hours, work, seven days a week. Some of those days must have been 120 hours or something nutty." But, that "You’re gonna go a little bonkers if you work 120 hours a week" Now, Musk said he is “down to 80 or 90” hours of work per week and “it’s pretty manageable.” 
This is still double the normal work week but he adds that “nobody ever changed the world on 40 hours a week” 
Musk is a fascinating character, and there probably is truth that if you want to succeed, you do need to stand out and go the extra mile. If that's a conscious choice of your, then make sure you find a healthy balance between succeeding and time for your loved ones/hobbies.
Work depends on others
Coders are not the only people involved in the software development process, and at times you'll find yourself waiting on others to complete their tasks in order for to proceed.
For example, if the software testers are working through a backlog, software developers may not have the choice to wait as they'll need to modify bugs simultaneously or asap in time for deployment.
Productivity Tips for Reducing Overtime and Getting out of Work Earlier
1. Reduce distractions
This is pretty obvious, but did you know it takes on average about 25 minutes (23 minutes and 15 seconds, to be exact) to refocus on a task following an interruption? 
Sometimes an interruption consists of a colleague asking you for a coffee. By all means, have one but if it's your 4th in the last hour, consider whether it's worth the impact on your time.
Having lost your focus, you're also more like to introduce errors in your code.
2. Ease back on Team Meetings
Although team meetings may be beneficial for working through a problem or making a collective decision, they may not necessarily be the best use of employees' time if they consist of chitchat or hours spent sharing information not relevant to everyone in the room.
I don't think there's a single team in any organization innocent of idling time like this. The truth is that often calling every member of a team to a status meeting isn't the best course of action and takes each employee away from their tasks.
Multiply the time by their hourly salary and the cost to companies becomes clear. Digital meetings, group chat or just plain old e-mail are oftentimes sufficient.
If All Fails, Work it to Your Favor
You can start to propose additional compensation such as a salary increase, or an improved position.
If you're working overtime, it probably means your company is short staffed and relies you. Consider leveraging that to your advantage in order to get ahead.
References  Elon Musk’s 2018 Interview With Kara Swisher, Vox
 The cost of interrupted work: more speed and stress. 2008 G Mark, D Gudith, U Klocke https://www.ics.uci.edu/~gmark/chi08-mark.pdf