Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "pass";
- $dbname = "db";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT timestamp_activated, timestamp_expire FROM user_subscriptions WHERE id = :id LIMIT 1";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $datetime1 = new DateTime('. $row["timestamp_activated"]. ');
- $datetime2 = new DateTime('. $row["timestamp_expire"]. ');
- $interval = $datetime1->diff($datetime2);
- echo $interval->format('%a');
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- SELECT TIMESTAMPDIFF(DAY, timestamp_activated, timestamp_expire) AS daysRemaining
- FROM user_subscriptions
- WHERE id = :id
- LIMIT 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement