OK, I have sorted it out so for anyone that is interested, this is what I did to make it work:-
Made sure that config.txt had the following lines:
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds1307
su'd and changed directory to /data/init.d and entered
cat > SetHWTime.sh
then pasted in
#!/system/bin/sh
BEGIN INIT INFO
# Exec: boot
# Type: permanent
END INIT INFO
insmod /boot/modules/rtc-ds1307.ko
ln -s /dev/rtc0 /dev/rtc
hwclock -l
hwclock -t
hwclock -s
Then CTL c and chmoded the file to 777
For whatever reason a file edited in Windows using notepad was the problem. I also found that to set the date to work correctly in the UK I had to use the date command to set the time 1 hour earlier than it really was, then use hwclock -w
Then a reboot set the system time correctly.
Note that I could have saved a line in the script by using hwclock -f /dev/rtc0 before each of the other options and not used the ln command