I'm new to Micropython and microcontrollers in general. I'm trying to create a script to run on a Raspberry Pi Pico that takes two time variables time1 = utime.time_ns() and time2 = utime.time_ns() and then subtracts time2 from time1 to give me the difference between the two times with nanosecond precision. When attempting to do this it prints out the value in nanoseconds rounded up to the second... for example, If there is 5 seconds between the two times the value returned is 5000000000... Is there a way that I can get a more accurate time? Am I going about this the wrong way? Thank you!!!
The processor crystal is not going to be accurate enough to get nanosecond precision.  You would have to replace it with a TCXO/OCXO crystal to get microsecond precision.  Another problem is crystal drift with temperatures.  The OCXO is a heated crystal.  A TCXO is a temperature compensated crystal.  As long as the temperature change a small a TCXO will likely get you in the microsecond ballpark.  Then comes the firmware issues.  Python is too slow for precise timing.  you would have to pick a compiled language to minimize the jitter issues.  I hope this helped.
Raspberry Pi Pico - Nanosecond Timer