Time problems in PHP script..

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
jaxx
Forum Newbie
Posts: 3
Joined: Sat May 22, 2010 4:36 pm

Time problems in PHP script..

Post by jaxx »

Following on from my last topic about the tickers...anyways I got help with that but now I have a new problem I'm hoping someone can help me out with.

I have 3 or 4 different tickers uploaded onto the server which belong to members, but ive noticed that the tickers all change to the next day at different times...I noticed one update to today at around 11 am, the others are still stuck on yesterday..they will change at some point today but not sure when.

Can somebody take a look at my script and see if theres anything wrong (im using same basic script for all)

I'm thinking they update at the same time the day after I uploaded to the server, could that be, if so how can I correct it?

Thankyou.

Code: Select all

<?php
header('content-type: image/png');

// ---------- DO NOT EDIT ANYTHING ABOVE ----------

$name = "I am";
$image = "olivmarie.png";

$due_day = 18;
$due_month = 7;
$due_year = 2010;

$font = 'angelina.ttf';
$fontsize = 16;
$slant = 0;
$margin_left = 120;
$margin_top = 220;

// shadow true or false
$shadow = true;
$shadow_left = 1;
$shadow_top = 1;

// ignore these, go down 17 lines to change the font colour
$image = imagecreatefrompng($image); 
$red = ImageColorAllocate($image, 255, 0, 0);
$green = ImageColorAllocate($image, 0, 153, 0);
$blue = ImageColorAllocate($image, 0, 0, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$white = ImageColorAllocate($image, 255, 255, 255);
$yellow = ImageColorAllocate($image, 255, 255, 0);
$aqua = ImageColorAllocate($image, 0, 255, 255);
$fuschia = ImageColorAllocate($image, 255, 0, 255);
$grey = ImageColorAllocate($image, 153, 153, 153);
$lightgrey = ImageColorAllocate($image, 187, 187, 187);
$silver = ImageColorAllocate($image, 204, 204, 204);
$teal = ImageColorAllocate($image, 0, 153, 153);
$lime = ImageColorAllocate($image, 0, 255, 0);
$navy = ImageColorAllocate($image, 0, 0, 153);
$purple = ImageColorAllocate($image, 153, 0, 153);
$maroon = ImageColorAllocate($image, 153, 0, 0);
$violetred = ImageColorAllocate($image, 139, 71, 93);

// don't forget the font colour
$fontcolor = $violetred;


// ---------- DO NOT EDIT ANYTHING BELOW ----------

// time variables
$today = mktime();
$due = mktime(0, 0, 0, $due_month, $due_day, $due_year);
$total_pregnancy = (60*60*24*280);

// get timecode for time left in pregnancy
$diff = ($total_pregnancy - ($due - $today));

// calculate weeks
$week = (60*60*24*(365/52));
$weeks = intval($diff / $week);
$diff = $diff % $week;

// calculate days
$day = (60*60*24); 
$days = intval($diff / $day);
$diff = $diff % $day;

// text to superimpose onto the image
$text = sprintf("%s %s weeks and %s days along!", $name, $weeks, $days); 

// make image
if ($shadow) {imagettftext($image, $fontsize, $slant, $margin_left+$shadow_left, $margin_top+$shadow_top, $lightgrey, $font, $text); }
imagettftext($image, $fontsize, $slant, $margin_left, $margin_top, $fontcolor, $font, $text);

// display image
imagepng($image);

// all done...
imagedestroy($image);
?>
if you look, her ticker says 33 days + 1 but she's not, she's 33 + 2....
Post Reply