Cutting 30 seconds from a legally acquired song and setting it as your own phone’s ringtone is a very different act, legally, from uploading that clip for others to download. The former typically falls within fair use or personal-use exceptions; the latter involves reproducing and transmitting someone else’s work to the public, which goes well beyond fair use and may constitute infringement.
The U.S. Copyright Office’s official fair-use guidance explains the four statutory factors of 17 U.S.C. §107: (1) the purpose and character of the use, including whether it is commercial; (2) the nature of the copyrighted work; (3) the amount and substantiality of the portion used relative to the whole; and (4) the effect of the use on the work’s potential market or value.
A 30-second clip used privately on your own device generally holds up under all four factors — non-commercial, a small portion, and no effect on the song’s market. Many jurisdictions outside the U.S. reach a similar result through explicit private-copying provisions; Taiwan’s Copyright Act (Articles 51 and 65), for example, permits non-profit personal reproduction within a reasonable scope.
Also note: streamed songs are not your files. Spotify, YouTube and similar services license you to stream, not to download and convert — ripping breaches the platform’s terms of service, an issue separate from copyright itself.