Sundar Nivash
Sundar Nivash

Reputation: 306

how could i get the system current date and time in codeigniter

I don't have much idea about automatic counter,working with date.I need to write a function to set counter for certain date. I have a table with the following structure.

CREATE TABLE IF NOT EXISTS `service_taxdate` (
  `tax` int(20) NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I need to get the system time and set the start date and when I reach end date, I need to insert an alert message. can some one help with code.

Upvotes: 2

Views: 4661

Answers (3)

mokNathal
mokNathal

Reputation: 553

If you want this to happen automatically you can use cron jobs. Alternatively,

SELECT * FROM service_taxdate WHERE end_date = curdate() and datediff(end_date, start_date)=your_counter;

To make trigger you have to keep alive system,login everyday and put this code on login or your default controller.

Upvotes: 2

Danyal Sandeelo
Danyal Sandeelo

Reputation: 12391

$date = date("y-m-d") 

would return you the system's date

<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
?>

output:

Today is 2015/06/29
Today is 2015.06.29
Today is 2015-06-29
Today is Monday

Upvotes: 3

Nithin Krishnan P
Nithin Krishnan P

Reputation: 758

<?php
$this->db->select('*');
$this->db->from('service_taxdate');
$this->db->where('end_date', date('Y-m-d'));
$query = $this->db->get();
// Produces: 
// SELECT * FROM service_taxdate
// WHER end_date =current date ( YYYY-mm-dd)
?>

Upvotes: 2

Related Questions