If you use /difficulty to change the difficulty of a map in singleplayer, it only persists until you change the game's difficulty.
Steps to reproduce:
1. Create a new map
2. Do /time set night
3. Do /summon zombie
4. Do /difficulty peaceful
5. The zombie despawns
6. Do /summon zombie
7. The zombie spawns, and then despawns instantly
8. Change your game difficulty to anything except peaceful or what it was before
9. Do /summon zombie
10. The zombie does NOT despawn
Currently the game difficulty is not stored with singleplayer worlds, and thus cannot be world dependant.