A method for device-to-device communication, comprising: acquiring, by a first user equipment, reference time, a first timing advance, and a device-to-device, D2D, data frame configuration, wherein the first timing advance represents a timing advance for the first user equipment to receive a first receiving subframe in a sequence of transmission subframes in the D2D data frame configuration, and the first receiving subframe is sent by a second user equipment; determining, by the first user equipment according to the reference time, the first timing advance, and the D2D data frame configuration, time for receiving the first receiving subframe; and determining, by the first user equipment according to the reference time, a second timing advance, and the D2D data frame configuration, time for sending a first sending subframe in a sequence of transmission subframes in the D2D data frame configuration, wherein the second timing advance represents a timing advance for the first user equipment to send the first sending subframe, wherein a serving base station of the first user equipment is the serving base station of the second user equipment, and wherein the second timing advance is a first timing offset between the first user equipment and the serving base station, and the first timing advance is determined according to at least one of the following timing offsets: a second timing offset between the second user equipment and the serving base station, and a third timing offset between the first user equipment and the second user equipment, and wherein the determining, by the first user equipment according to the reference time, the first timing advance, and the D2D data frame configuration, time for receiving the first receiving subframe comprises: determining time t for receiving the first receiving subframe as: t = t 0 − t 1 / 2 + t subframe wherein, t 0 is the reference time and is time when the first user equipment receives a data frame sent by the serving base station, t 1 is one of the second timing offset, or the third timing offset, t 1 /2 is the first timing advance, and t subframe represents a delay between the first receiving subframe and the first subframe that is in the D2D data frame configuration. acquiring, by a first user equipment, reference time, a first timing advance, and a device-to-device, D2D, data frame configuration, wherein the first timing advance represents a timing advance for the first user equipment to receive a first receiving subframe in a sequence of transmission subframes in the D2D data frame configuration, and the first receiving subframe is sent by a second user equipment; determining, by the first user equipment according to the reference time, the first timing advance, and the D2D data frame configuration, time for receiving the first receiving subframe; and determining, by the first user equipment according to the reference time, a second timing advance, and the D2D data frame configuration, time for sending a first sending subframe in a sequence of transmission subframes in the D2D data frame configuration, wherein the second timing advance represents a timing advance for the first user equipment to send the first sending subframe, wherein a serving base station of the first user equipment is the serving base station of the second user equipment, and wherein the second timing advance is a first timing offset between the first user equipment and the serving base station, and the first timing advance is determined according to at least one of the following timing offsets: a second timing offset between the second user equipment and the serving base station, and a third timing offset between the first user equipment and the second user equipment, and wherein the determining, by the first user equipment according to the reference time, the first timing advance, and the D2D data frame configuration, time for receiving the first receiving subframe comprises: determining time t for receiving the first receiving subframe as: t = t 0 − t 1 / 2 + t subframe wherein, t 0 is the reference time and is time when the first user equipment receives a data frame sent by the serving base station, t 1 is one of the second timing offset, or the third timing offset, t 1 /2 is the first timing advance, and t subframe represents a delay between the first receiving subframe and the first subframe that is in the D2D data frame configuration.