Welcome Guest, Not a member yet? Register   Sign In
help with time?
#1

[eluser]newbie boy[/eluser]
hi guys...

i need a function for time ...

time: 9:00 PM -> this is what the user will input where a user can select time using the html select of hours, minutes and AM or PM...

but i need to convert it to timestamp for my database like for the date function but for this one what i only need is the the time( hours, minutes and AM or PM ).

hope you could help me...

thanks again guys...
#2

[eluser]Thorpe Obazee[/eluser]
look into strtotime();
#3

[eluser]newbie boy[/eluser]
lost with strtotime...
#4

[eluser]Dam1an[/eluser]
Did you read the docs on PHP.net? can you be more specific then that you're lost?
#5

[eluser]newbie boy[/eluser]
i tried saving it in an military format of time where in AM is selected add 00 and for PM where it adds 1200 on the time selected...

like if 7:00 AM(+00) == 0700;
and if 7:00 PM(+1200) == 1900;

but my problem now is when 12:00 AM or PM is selected will output opposite data...

anyone there have a best solution in saving time to the database?

thanks...
#6

[eluser]Thorpe Obazee[/eluser]
[quote author="newbie boy" date="1246010603"]i tried saving it in an military format of time where in AM is selected add 00 and for PM where it adds 1200 on the time selected...

like if 7:00 AM(+00) == 0700;
and if 7:00 PM(+1200) == 1900;

but my problem now is when 12:00 AM or PM is selected will output opposite data...

anyone there have a best solution in saving time to the database?

thanks...[/quote]

I'm still not sure how you're lost. Did you try strtotime()?

You could always use TIMESTAMP or DATETIME to store time on a database

EDIT: Read that you're already using timestamp
#7

[eluser]slowgary[/eluser]
There's NO getting 'lost' using strtotime(). strtotime('9:00PM') will give you your timestamp. It's a VERY robust function and can generate a timestamp from the longest, most complex string, e.g.
Code:
strtotime('yesterday +3 weeks -2 days +1.5 hours')
#8

[eluser]newbie boy[/eluser]
wow. got it now!

thanks guys...

sorry for my stupidity...

until next time...
#9

[eluser]jedd[/eluser]
EDIT - dang, sorry, posted a reply to the wrong thread.
#10

[eluser]newbie boy[/eluser]
but guys...

how do I convert the strtotime() back to the 9:00 PM time format?

tried some solution but gives me the complete date format...

thanks guys...




Theme © iAndrew 2016 - Forum software by © MyBB