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;
}


blockchain

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

5 Blockchain Applications That Have Transformed the World of Technology

The blockchain is the decentralized database of the blocks of information, which gets recorded in the chain format and linked in a secured crypto graphical manner. This technology ensures proper safety of the data due to its secure nature, and it totally changes how people carry out transactions. It also brings about a faster and secure process of validating information needed to establish reliability.

What Is The Difference Between Blockchain And Bitcoin?

Our Blockchain Online Training will provide you to learn about Blockchain technology aspects with realty. Our Blockchain Course also includes live sessions, live Projects

Revolutionary Application of Blockchain Technology

Our Blockchain Online Training will provide you to learn about Blockchain technology aspects with realty. Our Blockchain Course also includes live sessions, live Projects

The Future Of Blockchain Technology And Cryptocurrency Applications

Our Blockchain Online Training will provide you to learn about Blockchain technology aspects with realty. Our Blockchain Course also includes live sessions, live Projects

Five Blockchain Trends for You to Consider this Year

Our Blockchain Online Training will provide you to learn about Blockchain technology aspects with realty. Our Blockchain Course also includes live sessions, live Projects