How to define 12pm everyday as UNIX timestamp?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

How to define 12pm everyday as UNIX timestamp?

Post by Matt Phelps »

I have a script which checks the time() and compares it with a another time, and if the time() now is past the trigger point (12 midday) then it should update the database.

My problem is finding a way of defining the unix timestamp for 12 midday. Is there a date function that I can use where I plug in (12,00) and it lets me know the unix timestamp for 12 midday on that day? If so then I can't seem to find it in the php manual.

Anyone got a clue how I might achieve this?
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Post by Matt Phelps »

I may have answered my own question. Can I use....?

Code: Select all

<?php
$midday = mktime(12, 00);
?>
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

try

Code: Select all

<?
$midday = mktime(12, 0, 0, date("n"), date("j"), date("Y"));
?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Matt Phelps wrote:I may have answered my own question. Can I use....?

Code: Select all

<?php
$midday = mktime(12, 00);
?>
That should work because the function will assume all the other arguments (such as month, day, year) are to be set as the current values.

You can easily do:

Code: Select all

<?php
$midday = mktime(12, 0);
echo date('d/m/Y H:i', $midday);
?>
to check though.

Mac
Last edited by twigletmac on Tue Mar 04, 2003 3:17 am, edited 1 time in total.
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Post by Matt Phelps »

Thanks all. :)
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time.
Didn't read that. Sorry.
Post Reply