WordPress widget value not save?

I also got this problem before. I try to use the (bool) but the problem still occured.

(bool) $instance['post_date']

will always return true unless $instance[‘post_date’] is an empty array, NULL or empty string

you can check this from http://php.net/manual/en/language.types.boolean.php

<?php
    var_dump((bool) "");        // bool(false)
    var_dump((bool) 1);         // bool(true)
    var_dump((bool) -2);        // bool(true)
    var_dump((bool) "foo");     // bool(true)
    var_dump((bool) 2.3e5);     // bool(true)
    var_dump((bool) array(12)); // bool(true)
    var_dump((bool) array());   // bool(false)
    var_dump((bool) "false");   // bool(true)
?>

so to handle this problem, I print the $instance[‘post_date’] and get the value ‘on’. So now my code currently look something like this and working perfectly.

<?php checked( $instance['post_date'], 'on' ); ?>