• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Current date

#1
[eluser]afro[/eluser]
Code:
Employees on leave from the <?php
    
        $now = time();
        $date  = mktime(0, 0, 0, date("m", $now)  , date("d", $now), date("Y", $now));  
        $today = getdate($date);
        $d = $today[mday];
        $m = $today[mon];
        $y = $today[year];
        echo "$d-$m-$y";

?>
             department.
am getting this error

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant mday - assumed 'mday'

Filename: views/onleave.php

Line Number: 39
help me out

#2
[eluser]InsiteFX[/eluser]
Take the m off of mday, it should be day!

InsiteFX

#3
[eluser]danmontgomery[/eluser]
Code:
$d = $today['mday'];
$m = $today['mon'];
$y = $today['year'];

Although there's really no need to do so much...

Code:
Employees on leave from the <?php echo date('j-n-Y', time()); ?> department

#4
[eluser]afro[/eluser]
This code gives me a time that is four hours behind the local time,

Code:
Employees on leave as at <?php echo date("H:i, F jS Y",time());?> from the <?php echo $this->input->post('department');?>  department are as follows.
what would be the problem.

#5
[eluser]wh1tel1te[/eluser]
[quote author="afro" date="1302863825"]This code gives me a time that is four hours behind the local time,

Code:
Employees on leave as at <?php echo date("H:i, F jS Y",time());?> from the <?php echo $this->input->post('department');?>  department are as follows.
what would be the problem.[/quote]
PHP time() function returns the server time, not the local time. If your server is located in a different country to you, you will get a different time back than your local time.

#6
[eluser]afro[/eluser]
Am using my laptop,and the time that is produced by the function is four hours behind the
system clock.

#7
[eluser]InsiteFX[/eluser]
Add this at the top of index.php below the PHP tag and see if it will help.

You will need to change for your country and city - country/city
Code:
date_default_timezone_set('America/New_York');

InsiteFX

#8
[eluser]afro[/eluser]
Thanks for that InsiteFX,
though I have a new problem, i want to pick the top three
record from a database table.
Code:
function onleave($limit, $offset)
{
    $limit = 3;
    date_default_timezone_set('Africa/Nairobi');
    $this->db->select('StaffName, Department, CommencementDate, MIN(Dateforreportingback), AppliedOn, Leave_Status');
    $this->db->from('appliedleaves');
    $where = "Leave_Status = 'ON'";
    $this->db->where($where);
    $today= date("Y-m-d");
    //$CommenceDate = "CommencementDate <='".$today."'";
    //$this->db->where($CommenceDate);
    $Reporting = "Dateforreportingback >='".$today."'";
    $this->db->where($Reporting);
    $this->db->limit($limit, $offset);
    $result['employee'] = $this->db->get()->result();
        
    return $result;
}

#9
[eluser]InsiteFX[/eluser]
I think you need to read the CodeIgniter User Guide - Ative Record!

Look at all your $db->where statements!

InsiteFX


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.