Philip IV , ( 8 April , 1605 â `` 17 September , 1665 ) was King of Spain between 1621 and 1665 He was also sovereign of the Spanish Netherlands and King of Portugal until 1640 . Philip IV ( , 8 April 1605 â `` 17 September 1665 ) was King of Spain between 1621 and 1665 , sovereign of the Spanish Netherlands , and King of Portugal ( as Philip III , ) until 1640 .