in reply to Yesterday's or last month's date?

For (1), you could call time() to get the epoch seconds, subtract the number of seconds in a day (24*60*60), then use localtime() to get the day/month/year back.