Codes call for different depths in different regions. They are there to cover the worst case situations. HOWEVER- a piece of NMW (or even plastic NMD) wire that is burried in 8-12" down is going to be safer than an extension cord running thru the mud.
If the wire is in sandy, or loamy soil (no sharp stones) and you are not going to hit it with a rototiller or shovel, it will last indefinitely. Frost won't hurt it, neither will wet ground. If it runs under a driveway, then put some sand in the trench to surround the wire and then cover it with a pressure treated 2x4 or 2x6, anything to protect it from damage.
You can also run a 3/4" plastic pipe underground and pull an extension cord into it. This way you can plug it into an outdoor outlet.
None of this is legal, and a home inspection MIGHT pick it up, but it sure beats an extension cord laying on the ground....
If you use a GFI circuit then it will trip if anything does start to short out.