Basic PHP Functions: timeIntro
Now how many times have you tried to test the time function in actionscript or php and see if it is equal to a string literal like 08:15, January 5, 2005 or an integer 22:06?....it doesn't work huh. Well that is because the computer does not return the actual time value as we would see it....it returns a unix timestamp
. This is simply the number of seconds that have elapsed since the epoch. The epoch is simply a date, January 1, 1970 at midnight. That simple. Now you are thinking...how the heck do you expect me to calculate such a larger number all of the time? Well here are some php functions and examples for time....time();
returns a Unix timestamp
examples:click the code to see the output<?php
Not much else to show you about this function without introducing you to more time/date functions in php.mktime();
Returns a Unix timestamp
for a date. In other words it converts a date that we would normally read into a Unix timestamp
which your php scripts could use.
int mktime ( hours, minutes, seconds, month, day, year [, is_dst]) *note: arguments can be excluded from right to left
Everything is pretty self explainable....you could leave out the last argument. is_dst -
It is for daylight savings. It defaults to a value of "-1". You put "0" if it is not daylight savings time and "1" if it is. If you let it default to the value of "-1" then php tries to figure it out for you.
examples:click the code to see the output
Lets say that you wanted to change a date of November 14, 1983 (my birth date) to a timestamp....<?php
That is "0" for the hours, "0" for the minutes, "0 for the seconds, "11" for the 11th month of the year November, "14" for the day of the month, and "1983" for the year. Now check out this code....<?php
This just shows you how you can use either a two or four digit integer for the year. They both output the same thing.
aight too be continued like all of my other stuff.....I know. sorry. I just got a couple ups packages for over a grand in new computer parts. I am going to go put a computer together (or at least try, lol).