arduino UNO and DS1307 RTC

I am using a DS1307 based RTC got from a local store which is same as the sparkfun RTC
I used sparlkfun library
and i used the below sketch to program the RTC with the current system time

#include <Wire.h>
#include "RTClib.h"

RTC_Millis rtc;

void setup () {
  Serial.begin(57600);
  rtc.begin(DateTime(F(__DATE__), F(__TIME__)));
}
void loop () {
  DateTime now = rtc.now();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(' ');
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();
  delay(1000);
}

and obtained the correct output in the serial monitor

but
i again reprogrammed the arduino removing the rtc time programming
and the out put at the serial monitor is showing a specific date and time as in the figure

I think the time in the RTC should not be changed with the change in arduino sketch so what is the reason for this change in time

Do not use RTC_Millis rtc;

Instead, use RTC_DS1307 rtc;

RTC_Millis is using the millis() function with the code of the library, and is not actually addressing the RTC and its registers. Look at the example sketches for RTClib.h and see the differences between the softrtc sketch and the ds1307 sketch.

#include <Wire.h>
#include "RTClib.h"

#if defined(ARDUINO_ARCH_SAMD)  // for Zero, output on USB Serial console
  #define Serial SerialUSB
#endif

RTC_DS1307 rtc;

void setup () {
 while (!Serial);  // for Leonardo/Micro/Zero

 Serial.begin(57600);
 Wire.begin();
 rtc.begin();

 if (! rtc.isrunning()) {
   Serial.println("RTC is NOT running!");
   // following line sets the RTC to the date & time this sketch was compiled
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
   // This line sets the RTC with an explicit date & time, for example to set
   // January 21, 2014 at 3am you would call:
   // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
 }
}

void loop () {
   DateTime now = rtc.now();
   
   Serial.print(now.year(), DEC);
   Serial.print('/');
   Serial.print(now.month(), DEC);
   Serial.print('/');
   Serial.print(now.day(), DEC);
   Serial.print(' ');
   Serial.print(now.hour(), DEC);
   Serial.print(':');
   Serial.print(now.minute(), DEC);
   Serial.print(':');
   Serial.print(now.second(), DEC);
   Serial.println();
   
   Serial.print(" since midnight 1/1/1970 = ");
   Serial.print(now.unixtime());
   Serial.print("s = ");
   Serial.print(now.unixtime() / 86400L);
   Serial.println("d");
   
   // calculate a date which is 7 days and 30 seconds into the future
   DateTime future (now.unixtime() + 7 * 86400L + 30);
   
   Serial.print(" now + 7d + 30s: ");
   Serial.print(future.year(), DEC);
   Serial.print('/');
   Serial.print(future.month(), DEC);
   Serial.print('/');
   Serial.print(future.day(), DEC);
   Serial.print(' ');
   Serial.print(future.hour(), DEC);
   Serial.print(':');
   Serial.print(future.minute(), DEC);
   Serial.print(':');
   Serial.print(future.second(), DEC);
   Serial.println();
   
   Serial.println();
   delay(3000);
}

I used the above code but the output given is as shown

It looks like you are running an Arduino Zero. I have no direct experience with that board, but there have been several forum postings on i2c problems with the Zero, and I think you can be running into several potential problems.

First, make sure that you are using the SDA/SCL pins and not A4/A5.

Second, there is the issue of pullup resistors on SDA/SCL. I'm not sure if your rtc module has built in pullups and if they are to 5v. I think you would want external pullups to 3.3v.

Third, the DS1307 is a 5v device. If you are powering it off 3.3v it will drop into battery power and block the i2c communication.

I would also suggest that you go back and modify the title of your posting to something like "ArduinoZero and DS1307 RTC Module"

it is not an arduino Zero it is uno the circuit board of rtc has the pull ups and the circuit is powered by the 5v pin from the arduino

The code you provided in post #2 works on a Uno with my ds1307 module.

The first thing to test is whether or not the module is recognized on the i2c bus. Please run the following code, and post the result.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

did changing the NVRAM values affect the system
the I2C scanner found no devices

the current NVRAM Values are

Your first priority is to get the DS1307 recognized on the i2c bus. It should be at address 0x68.

The fact that the scanner sketch does not hang up indicates that power and ground are OK, and that SDA and SCL are not shorted together or to ground, so focus on the continuity of the SDA/SCl (A4/A5) connections.

How do you have the module connected to the UNO?

If you are using jumper cables, I would replace then as they can be defective. If you are using a breadboard for connections, try using a different location as they can be defective. If you have a schematic of your module, check carefully for continuity between the i2c legs on the chip and the wires coming to the module.

I would also write some simple code to do both analog and digital reads on pins A4/A5 (test once with the pins jumpered to 5v and then a second time jumpered to ground) to see if they work properly and the UNO is not defective.

did changing the NVRAM values affect the system

No. The RTClib.h library is written so that the address values for the NVRAM read/writes do not overlap with the timekeeper registers. I am confused by why you actually see nvram values when the chip is not seen on the bus, but there may be something about how the library handles the buffer and storage locations of the read/write values such that the written data is taken by the read function from previously used memory locations.