Page 1 of 1

How to define 12pm everyday as UNIX timestamp?

Posted: Sun Mar 02, 2003 12:59 pm
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?

Posted: Sun Mar 02, 2003 1:03 pm
by Matt Phelps
I may have answered my own question. Can I use....?

Code: Select all

<?php
$midday = mktime(12, 00);
?>

Posted: Sun Mar 02, 2003 5:21 pm
by hob_goblin
try

Code: Select all

<?
$midday = mktime(12, 0, 0, date("n"), date("j"), date("Y"));
?>

Posted: Mon Mar 03, 2003 2:27 am
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

Posted: Mon Mar 03, 2003 10:39 am
by Matt Phelps
Thanks all. :)

Posted: Mon Mar 03, 2003 5:29 pm
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.