Changing due date for a student suddenly Today I had two students never working on their assignment but looking at their phones the whole class. I did not warn them that I will collect their work but I told them to put their phones away. After that I told the students to turn their work in even though it wasn't the due date. I am planning to put their grade into the gradebook. Am I allowed to do this?
It's unlikely you can do this.

Unless you have a statement in your class syllabus that:


explicitly bans the use of cell phones in class and
specifies that you can make students turn work in early,


this is probably going too far beyond your actual authority and in principle could be overturned were the students to appeal. 

If you're going to have students working on homework assignments in-class then it is probably best to institute a "participation" component to the grade, which you would then be certainly entitled to lower on account of their lack of participation during class. But unless that's already built in, there's not much you can really do here.