If you are using Ubuntu
then add below lines in "/etc/rc0.d/S60umountroot" at the beginning.
Log="/var/log/uptime.log"
echo "$(date) $(/usr/bin/uptime)" >> "${Log}"
or you can simply use `logger`
logger "UPTIME: $(uptime)"
then it will gives details in `/var/log/syslog` or `/var/log/messages`
Note :- Please careful edit this file
If you are using CentOs, then do the same in "/etc/rc.d/rc0.d/S01halt", but note that it should be added in beginning of the file.