Background: Time flexibility in a company is very important to me. In my case, I am a person that has no troubles in waking up earlier, so I made clear in my interview if it was going to be a problem if I could start working earlier, and leave earlier. The CEO (which I knew beforehand and have a good relationship with) had no problem with that during the interview.
I started working (it was a workspace, so the office was a small room for 4 people) at 8 and left at 17. Most of the time I was by myself, sometimes with the project manager and another colleague) without problems. So most of the times I had lunch in 5 minutes from my lunch box and kept working, so as not to waste time and leave earlier as the relationship and atmosphere was not going to get "that kind of friendly, just professional".
The issue: The other colleague had no problem at all with me and my timings, as my job was always done and I put the effort, but the manager always came later (ergo, left later). So sometimes the manager wouldd come at 11, but expect me to leave when he was leaving. I stayed 1-2 more hours almost every day. Sometimes the manager was very subtle (him making comments when I started packing up, or adding last minute tasks that were indeed not short) but sometimes direct as well "oh you are leaving early?" (I would always say I started at 8 but, deaph ears it seems.). I even got his late texts some days, and worked home (some days at 22). After a few weeks, I had a doctor's appointment at 17:30, which was outside my working time, and still my manager asked me for the medical proof to bring it on the next day (in some countries it is compulsory for the doctor to sign the document to demonstrate you really went to the doctor and you didn't slack off). That really angered me (specially because he did not know the kind of doctor, and even that can be sensible information) and I told the CEO. He told me not to worry about the manager, that he is just a very demanding person but is happy with my work and wants me to keep learning.
This is in the past but, how to handle something similar if it happens again (especially if you do not have a lot of working experience, so I dont know how to treat these situations)? In this case, although my working experience is low, I'd communicate with HR, but in this case it is a very small company where HR was done by the CEO.
The company had time flexibility, so I started at some hour I could choose (8am) and my manager 2-3-4 hours later. He "expected" me to stay longer every day, sent me texts (with new tasks or checks) outside work hours (even 21-22 sometimes) like "work on this so tomorrow we are ahead." He even asked me for a medical proof of a doctor's appointment even though the appointment was not only outside my working hours but that day I was already staying a bit longer.