Jump to content
php.lv forumi

kur kļūda?


renathy

Recommended Posts

Kur ir kļūda?

 

function combine_date_time($date, $time)
{
$t = explode(".",$time);
$d = explode(".",$date);
// echo $t[0].' '; echo $t[1].' '; echo $d[0].' '; echo $d[1].' '; echo $d[2].' ';
return mktime($hour=$t[0], $minute=$t[1], $second=0, $month=$d[1], $day=$d[0], $year=$d[2]);
}

 

$t = '10.50';
$d = '21.10.2009';  
echo combine_date_time($d, $t);

 

Rezultāts ir 1256111400, bet it kā jābūt 1256122200 (vismaz tā šeit rāda - http://www.onlineconversion.com/unix_time.htm)

 

+ cik saprotu, tad te funkcijā vēl trūkst apstrāde, kas noņem priekšējās nulles (piemēram, laikam 01 jāpāraisa par 1 utt).

Edited by renathy
Link to comment
Share on other sites

Aleksejs: Es biju domājusi strtotime().

 

Marcis: tavs ietektais strtotime variants man nestrādā.

 

ja

date = 15.11.2009

time = 21.45

 

tad strtotime rezultāts ir 1258339500

bet jābūt 1268343900

Edited by renathy
Link to comment
Share on other sites

The function expects to be given a string containing a US English date format.

un

This function will use the TZ environment variable (if available) to calculate the timestamp. Since PHP 5.1.0 there are easier ways to define the timezone that is used across all date/time functions. That process is explained in the date_default_timezone_get() function page.

 

Es parasti ar explode() sadalu padoto teksta virkni trijās daļās un tad tās iebaroju mktime() funkcijai kā attiecīgos parametrus.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...