PDA

View Full Version : Need some help turning string into time


JJR512
02-20-2002, 06:51 AM
Suppose you have this string: 200754

The first two digits are today's day of the month (as in Feb. 20). The next two digits are the hour of the day in 24-hour format, and the final two digits are the minutes of the hour (the time in that string is 07:54).

The time zone will always be GMT for the string.

How can this be converted to vBulletin's date/time format, which is something like "1014047921".

BTW, is Zulu or UTC the same time as GMT?

JJR512
02-20-2002, 06:57 AM
Hmm...I think I just realized how to split apart the string.
preg_match("/([0-9]{2})([0-9]{2})([0-9]{2})"/,200754,$matches)
That ought to split it apart into three pairs of two digits, right? And each pair is identified by $matches[1] or 2 or 3.

That just leaves converting the numbers into vB's format...

Admin
02-20-2002, 12:16 PM
You can't do what you are trying to do, because your string misses the year and month indications. And since vBulletin uses the Unix timestamp, you must have those...

JJR512
02-21-2002, 01:35 AM
Sorry, I forgot to explain more.

The month and year should be assumed to be the present.

The time format 200754Z is part of a report that gets published about every hour or so. So it is conceivable that someone just after midnight of the last day of the month could be looking at a report that is from last month. There will need to be some code that checks for that kind of thing.

Radon3k
02-21-2002, 02:13 AM
JJR512, I can't help you with your PHP problems, but I can tell you that GMT, Zulu, and UTC are all the same time ;)