BLOCKCHAIN--getting different output of sha256 hash for same data

BLOCKCHAIN--getting different output of sha256 hash for same data

I am a beginner in blockchain programming (its only been 3 days). When coding a simple blockchain, I include TIMESTAMP to pass through the sha256() along with other data, I obtain a different hash result for same data each time i restart my program. when i omit the TIMESTAMP from my program same hash is generated for same data everytime. Also, i am c++ person and i am using time(&time_t) function for generating my TIMESTAMP.

I am a beginner in blockchain programming (its only been 3 days). When coding a simple blockchain, I include TIMESTAMP to pass through the sha256() along with other data, I obtain a different hash result for same data each time i restart my program. when i omit the TIMESTAMP from my program same hash is generated for same data everytime. Also, i am c++ person and i am using time(&time_t) function for generating my TIMESTAMP.

also wanted to know that is it OK to have different hash result for same data (very new to blockchain.. sorry)

EDIT-- this is the function using TIMESTAMP and sha256..

string Hash_fn()
{
    string toHash = to_string(data.amount) + data.Sender + data.Recevier +to_string(data.timeStamp)+to_string(nonce);
    return sha256(toHash);

}

and this data is just an object of this class

class TData{public:
double amount;
string Sender;
string Recevier;
time_t timeStamp;
TData(){}
TData(double amt, string S, string R, time_t T)
{
    amount = amt;
    Sender = S;
    Recevier = R;
    timeStamp = T;
}


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Blockchain Application Development Company

Codezeros is a top **[Blockchain solution and service provider](https://www.codezeros.com/ "Blockchain solution and service provider")** company which reinvents business with Blockchain solutions. Our Blockchain development solutions fortify the...

Top 10 Best Blockchain Programming Language for Blockchain Programmer

We aim at equipping you with every necessary knowledge of the best programming languages for blockchain and you'll learn more 10 Best Blockchain Programming Language for Programmer: C++, Java, Python, Ruby, Solidity, Go, JavaScript...

Blockchain Certification Training - Blockchain Course - Intellipaat

Enroll for Blockchain certification course online. Best Blockchain Training created with IBM to learn blockchain technology, Cryptocurrency, Bitcoin & become Blockchain Developer.