<?php
// db.php - update DB credentials as needed

// Set PHP default timezone to Bangladesh Time (BDT)
date_default_timezone_set('Asia/Dhaka'); // BDT (UTC+6)

// Database credentials
$DB_HOST = 'localhost';
$DB_USER = 'jeweller_santojwelars';
$DB_PASS = 'jeweller_santojwelars';
$DB_NAME = 'jeweller_santojwelars';

// Connect
$conn = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if ($conn->connect_error) {
    die('Database connection error: ' . $conn->connect_error);
}
$conn->set_charset('utf8mb4');

// Set MySQL session time_zone to +06:00 (BDT) so NOW(), CURRENT_TIMESTAMP etc. in SQL use BDT
// Note: requires MySQL timezone tables to be populated for named zones; offset works reliably.
if ($conn->query("SET time_zone = '+06:00'") === false) {
    // Log but don't die — connection still usable for most apps
    error_log('Failed to set MySQL time_zone: ' . $conn->error);
}

/**
 * Helper: get current BDT datetime as string.
 * Usage: bdt_now() or bdt_now('Y-m-d') or bdt_now('Y-m-d H:i')
 */
function bdt_now($format = 'Y-m-d H:i:s') {
    return date($format);
}
?>
