php time format !+reps!
#1

hi,

sorry for this php question but its another tiny problem:

PHP код:
//i select time from the database where the user accounts are saved.
//The time saved in the "time" column is an unix timestamp saved with gettime(); on the server.
//So there is e.g. 52 saved in the time column. That would be 52 seconds.
//But if the player plays longer the number gets bigger and my question is how i can format it
//correctly like: Hours:Minnutes:Seconds in 00:00:00 format?
<?php
$result 
"SELECT time FROM Users"
$row mysql_query($result) or die("Data transfer failed!");
<
td><?=$pTime $row['time'];
echo 
date("H:i:s"$pTime);?></td>
?>
//it shows the time but not correctly. So what im doing wrong?
thx in advance
Reply
#2

Is the time beign SAVED correctly? Also, what does it output and what should it output?
Reply
#3

yes, it is saved correctly, the problem is only the output on the website via php.

e.g. if there is this saved: 54
this would be 54 seconds so it should be displayed like this: 00:00:54
But i get: 5401:00:54

For players that have played 0 time on the server (and the certain column is 0 in the database) it shows: 001:00:00 but it should show: 00:00:00

I really hope someone can help me
Reply
#4

help please
Reply
#5

Um, no ideea. What about 'h' instead of 'H' ?
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Apologising for posting something off topic does not mean you can then continue to do it regardless, it means you know it is wrong and should find somewhere better suited for the question but chose to ignore that.
I really respect u as a scripter/programmer but as you always say you are very busy and have no time (e.g. to answer pm's etc.) you should either answer the questions or leave it.

As ive seen u have enough time to make answers like this one on this topic or replies like these:
(just to name one of a lot examples!)

https://sampforum.blast.hk/showthread.php?tid=301440

or taking motivation from people that put very much effort into a tutorial (not everyone is that interested and good in scripting/programming cause there are also other jobs on this world...)

https://sampforum.blast.hk/showthread.php?tid=301435&page=2

It is ok to snub people like me or others sometimes so they can learn etc. but please also understand not everyone is an ******!

i dont want to be ruge or offend someone, just saying my opinion, others might have another opinion.

Im sorry for going offtopic
Yes, i know that going offtopic was wrong once again but what would be the difference between machines/computers and human beeings if we would just follow strict rules?

at Berlovan: thx, already tried also the same result
Reply
#7

How do you save it on the server ? Is it ith H:m or do you even save the hours ?
Reply
#8

no im only saving an unix timestamp i got with gettime();
So theres only one single column in the database for the time.
E.g. the number looks like this: 125145114

with certain php functions u can format that number into different time formats.
Theoretically my code should work but it doesnt and im really weird about that
Reply
#9

* sleepysnowflake gives up.
I know no PHP but how would you format that number ? Unix just counds secounds form when it was first made, right ? Or is there something I do not know.
Reply
#10

if u use gettime() it gets the actual time and date.
By subtracting 2 different unix timestamps u can get the time (in seconds) it lasted from the first to the second timestamp.

Php has functions to convert this number into different formats.

http://php.net/manual/de/function.date.php
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)