Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:23:06+00:00 2026-06-04T04:23:06+00:00

I am trying to assign a block of content (on a webpage) a randomly

  • 0

I am trying to assign a block of content (on a webpage) a randomly generated number that is based between todays date (whatever that will be) and a fixed number. For some reason there is dramatic difference in the sorts of numbers being outputted. For example when I test my code locally the numbers generated are good enough for me (in the positive) but when on an actual live server they are generally the opposite and are negative numbers.

This is my one liner:

<?php $today=date('YmdHi'); echo rand(201203140906, $today); ?>

Basically ‘201203140906’ is the Year, Month, Day, Hour.

Is this good or bad? Are there better ways to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:23:07+00:00Added an answer on June 4, 2026 at 4:23 am

    On a 32-bit system, the largest value that can be held in an INT is 2147483647.

    http://php.net/manual/en/language.types.integer.php

    If your local machine is 64 bit and your server is 32 bit, they will have different size limits. The server will not be able to handle an integer as large as 201203140906.

    You may be able to randomly generate a smaller number and then add that to 201203140906.

    Like this perhaps:

    $today = date('YmdHi');
    $startDate = date('YmdHi', strtotime('2012-03-14 09:06:00'));
    $range = $today - $startDate;
    $rand = rand(0, $range);
    echo "$rand and " . ($startDate + $rand);
    

    OR you can do this to generate a random date in the last ten days:

    $today = date('YmdHi');
    $startDate = date('YmdHi', strtotime('-10 days'));
    $range = $today - $startDate;
    $rand = rand(0, $range);
    echo "$rand and " . ($startDate + $rand);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to assign a block to a button object so that each
I'm trying to assign the output of this command ( that is in my
I'm trying to assign a block of javascript in Shortcut Manager, chrome.tabs.getSelected(null, function(tab) {
I get this error when trying to define and assign a block: int (^bl)(int)
I'm trying to assign an id to a component inside a <ui:repeat> like that:
I'm trying to write an expression that will call ToString on a property and
So i'm trying to assign a hyperlink to a single word in a {p}
I am trying to assign objects in an NSMutableArray using this code - (IBAction)variablePressed:(UIButton
I'm trying to assign integer to a newly created row: INSERT INTO wcategory (name,
I'm trying to assign DataContext to a MenuItem, which is part of ListBox. <Style

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.