'by tonight' or 'within tonight'

  1. Finish the work within tonight.
  2. Finish the work by tonight.

Are they both correct? The meaning of the two sentences might be different.


By tonight means by the end of the current day.

Within tonight is not an idiomatic phrase. It could be understood to mean during the current night, but for that we would normally say by [the] morning.

If you are a beginner in English you might find https://ell.stackexchange.com/questions more helpful.