Trying to get UNIX timestamp since epoch in milliseconds

I have successfully obtained time since epoch time in milliseconds by syncing time with the NTP client. Then whenever I wanted to get time in milliseconds I would call time_t time=time(NULL), and simply cast to long long or unsigned long long variable= (unsigned long long) time*1000; I have no clue what happened but I started receiving outputs with 3 zeros at the end of the timestamp e. g. 1234567891000 and only the seconds change 1234567892000 and so on. I have then tried with chrono and i get the same issue. Here is the chrono code that prints current timestamp (attempts to print it in milliseconds):

#include <chrono> 
#include <cstring>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
    char buff[100];
  	auto millisecondsSinceEpoch= (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())).count();
    std::string millisecondsStr = std::to_string(millisecondsSinceEpoch);
    strcpy(buff, millisecondsStr.c_str());
    //sprintf(buff,"Current time: %lld",t);
    Serial.println(buff);
    delay(237);
}

Check how is it done by the MachineControl library