Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Displaying Local Date In Specific Format


i'm trying to decide whether to use PHP or JavaScript to display a date on a website. what i'm wondering is where does PHP take the date from, the server or the client (ie will timezone become a factor). aswell as this, is there a simple way to allow the date to be displayed as: "22nd" "1st" or "14th" instead of "22" "1" or "14"?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Always Local Time & Date Format?
Is there a script available that would re-format a time & date always
according to the users' setting?

Some setting that would be read by the language set in the browser or from
the IP?

Displaying The Date In A Different Format!
I have a row called Date in the databse which is saved as 0000-00-00 When I try to echo it, it shows like that 2007-04-16 Maybe because I use this normal code: echo $row['Date']; How can I display it like that:16-04-2007

Converting A Date Format (dd/mm/yyyy) Into A Time() Format
I want to convert a date in the format (dd/mm/yyyy) into a time() style format so I can compare it against the current time and only use information where its date is ahead of the current time.

Displaying Local Time
How do you display a users local time. I have looked through some help files and they seem to all seem to be showing me how to use the time in conjuction with something else.

Displaying Specific Number Of Queries.
If I wanted to only display the first 10 queries from MySQL on my webpage, how would I do that? Also, say if I wanted to only display queries 11 - 20, how would I do that?

Displaying Links To Specific Users
I am currently working on a project whereby users login to my website and then using a form add new quick links/tabs to their navigation bar. So for instance if the user had 'home/search engines/favourites' as links on their navigation bar and they wanted to add auction sites as a group link they fill out the form which then posts the data into a flat file database. (usertabs.txt)

So far i can make the form send the link name, URL and attach the username of the person adding links so to make a id for the link name and URL. So in the flat file the structure is presently: Code:

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

Displaying Value As Epoch Format
I've been fiddling around and and come up with a solution for the current date
but when i try and display the results for the previous 5 days i am running into a slight
problem. This is what i have so far: PHP Code:

Displaying .txt Files And Maintainint Their Format Using Php
I wish to display .txt files within a php page. I have found out how to do this but any formatting such as paragraphs and tabs is lost. Can anyone help me with how to display the txt file as it is, formatting included? It is simply so we can update our Community Centre website with ease via txt files.

Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format.  For example the following text in this format including the lines in stored in the database:

Quote“Hello,

Welcome to the news for 11/06/07.

Thanks”
When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this.  Quote“Hello, Welcome to the news for 11/06/07. Thanks”  How do I get it to display in the format it in displayed in the database?

Format Source Code For Displaying On A Web Page
Is there a good function or plugin out there to format my source code examples?  I'm writing an article for a web page and want a very simple source code formatter.  Eg: code in black, comments in red, quoted items blue, key words green, class names bolded.

WHERE Date = Specific Dates
What is the sql query to have the dates be specific to a specific time frame? Such as all records = August. I have tried 2003-08-% but that didn't work.

Specific Date And Time...
I've created a new site, and its going to be online in September. Until then, i would like to have online a simple countdown that will display the time left until that day, and when we reach that date the new web page would appear automatically.

Grab Data From Mysql For Specific Date
I am trying to make some code with PHP and MySQL for displaying data from table corresponding to current server date (only field with date corresponding to server date will show on webpage). PHP Code:

Finding A Zodiac Sign For A Specific Date.
I got a specific date and I want to show the correct zodiac sign for that date.

Determining Local Date/time, Given GMT And Offset
I'm trying to create a function that returns the local date/time if you feed it a GMT date/time and the local offset.  For example i live in MST so i think it's GMT-7.  This is the function i've created, but it's returning weird values. didn't work for me last night, but mysteriously worked this morning.

maybe something screwy with AM vs PM? I'm passing the date in the format "Y-m-d H:i:s". I'm not so good with date calculations obviously. Code:

Pulling Date-specific Data From Flat File
I'm almost a complete newbie to using PHP and I was hoping one of you
guys can point me in the right direction. I'm working on a site for a
brand of handmade fruit juice and it only needs one bit of dynamic
content: the info on what fruit is in the juice and where it is coming
from (vendor, country etc.) today and tomorrow (the content of the
juice is different everyday). So I thought it would be easiest to put
that information in a flat file (an Excel file would be ideal but a
plain text would do too) on a weekly basis and try to pull out the
needed info with PHP. Except I don't know how yet. I don't expect any
of you to do the work for me but if someone could point me to which
functions of PHP I should do some research on, I'd be most grateful.

Date Format ...
I have dates with this format

1 9 99 00:00:00

I want to transform it in yyyy-mm-dd

how can I do with php ?

Help On Date Format
I have this page where user select month day and year from a drop down list and when the user pass it to selectdate2.php
it will be as treated one variable in a date format yyyy-mm-dd. any suggestion?

this is the first page named selectdate.php

<select size="1" name="month">
<option>01</option>
<option>12</option>
</select>
<select size="1" name="day">
<option>01</option>
<option>31</option>
</select>
<select size="1" name="year">
<option>2000</option>
<option>2003</option>
</select>

Date Format
I have a script running (with great effort and help from the group) that displays a date from a database and the amount of days to that date.

I would like to change the date into a more "human" format. The date now displays:

2002-12-08

I would like to change it to:

Sunday, December 08th

Is this a property of mktime()?

Date Format
Can a guru show me the equivalent of this code (that I use in Mysql), but need to replicate in MSSQL....

[MySQL CODE]
Date_format(Orderdate, '%y-%m') as period .... more statements
[/MySQL CODE]

How do I do this in MSSQL? The date is in this format in MSSQL DB.: 2003-11-30 00:00:00

**I have tried various things but my efforts are failing!

Date Format
I have a date in dd/mm/yyyy format i.e. 15/03/2007 The problem is that when I am storing this in MySql it uses yyyy/mm/dd format so the value stored in the DB ends up being 2015-03-20 Does anyone know how I can get around this problem?

Date Format
I can't figure out why the date did not came out correctly.

I wrote
Quote<?php
$b = "2006-03-01";
print date("m/d/y",$b);
?>

It suppose to come out as 01/Mar/06. But what what came out was 01/Jan/70. 
Can anyone tell me why this happens.

Date Format
if i have a date stored in my DB as 11/09/2007

is there anyway i can change it to 11th Sep once i have pulled it from the DB?

Time/Date Format
I'm pretty sure there is a way to do this, but I don't know what the code is to do what I'm trying to get.

Is there a way to get the current date and time in YYYYMMDDHHNNSS format (as an example, 20001030111100)? I would guess you can but I don't know what the code is.

Date Format Function Gone Bad
I am trying to clean up a DATETIME value from a Mysql database for presentation. So I am using the following basic function right out of devsheds recent article:

function cleanDate($val)
{
$arr = explode ("-", $val);
return date("M d, Y", mktime(0,0,0, $arg[1], $arg[2], $arg[0]));
}

Then feeding it a Mysql like DATETIME value for a test and echoing it to he page. Also I have added a current date echo to ensure that "it" knows that much.

$date = "2002-03-18 11:19:57";
echo "Updated " .cleanDate($date);
echo "<br>Todays date: " .date("F d, Y", mktime());

and here's my output....

Updated Dec 31, 1969
Todays date: March 20, 2002

Where have I gone wrong?

Date Format From MySQL In PHP
I've recently been successful in converting the MySQL date format YYYY-MM-DD to DD-MM-YYYY, but does anyone know of a way to actually format it so that it displays the corresponding months?

eg. 25-10-2003 = 25 Oct 2003

Convert A Date Format
I am displaying records from a table including a stored date. When
display $row[Date], i get the obvious 2006-05-21. However this is not
what the guy wants. He wants 21-May-2006.

I have tried several conversion functions but without success. I could
do a long winded function, but i hoped there would be a simple
solution.

MySQL / PHP Date Format
I am using php to call info from a mysql database. My date comes in format yyyy-mm-dd but I want it in dd-mm-yyyy. I know I need to use something like:

SELECT DATE FORMAT (date, %d-%m-%y)

But I'm not sure how to include it in my query which is also calling other items from the database:

$result1 = mysql_query("SELECT * FROM practice AS p, project AS t, regions AS r, gpcats AS c WHERE p.id = t.id AND t.region = r.region AND p.gpid = c.gpid AND gptext LIKE '%$search%' AND $region=0 AND '$cat'=&#390;'GROUP BY p.gpid ORDER BY verified DESC"

SQL Statement With DATE Format
i want to compare dates. The dates are like "2007-06-25".
I tried this:
$SQLString = "SELECT * FROM myDB.myTABLE WHERE dat_start = $act_dat";
But it didn't work.
What can I do?

Changing Date Format
If I fetch a date from a mysql field and the date is: 2006-01-12 00:00:00

Is there a way I can reformat it in php to lose the hr.min.sec so that I am just left with the date 2006-01-12??

Change Date Format
I would like to know how to change the date format in 31-JUL-2007 to 07-31-2007?

Changing Date Format
i hve a date variable in mm-dd-yyyy format how can i change it to mysql default format i.e., yyyy-mm-dd format ...

From Varchar To Date Format
i am having one problem with mysql.Previously i have created one Date field as varchar format.Now i want change that field as date fromat and also the data should be there as date format whatever i have stored previously.

Searchable Date Format
Whats the best searchable date format for php mysql ? Im after only showing news on and after the publish date specified.

So i first need to know which date() i should be using..

Iv researched date() and got date("Y-m-d"); , but is this searchable?

Also would need to know how to show only articles that have todays date or previous dates ( not future dates etc ).

How To Manupulate MySQL Date Format In PHP?
MySQL date format is yyyy-dd-mm. how can i make full manupulation of the date with php? For example, how can i make the date to 29-september-2002 and others manupulation.

Date Validation YYYY-MM-DD Format
Hi, I am using forms which input dates into a mysql table, these work fine. However I would like to validate these into the correct format which is YYYY-MM-DD. So I am guessing I need an ereg function which looks for a string of 4 followed by a dash, then 2 then a dash and finally two more.
The code I have so far is:

$date_pattern = "([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})";
if (!preg_match($date_pattern,$EventStart))
{
echo ("<br>Wrong date format");
$FormValid="False";
}

MySql Query, Php Date Format.
This is actually 2 questions, but they go to gethere so I'm asking them as one. First, how do I write a MySql query that returns all the rows that have a date in the date collum that is newer than todays date? Then I need to take those rows, format the date in them and then print them in a table.

MySQL > Timestamp > Date Format
i know that MySQL uses the unix timestamp thing, and i can display the date by doing this
PHP Code:

Date Stored In DB In The Following Format: 2004-06-29 09:06:36+01
I am trying to convert a date in the following format with the date
function (i.e. date("d/m/y", strtotime($dbdate));):

2004-06-29 09:06:36+01

The database was created by another programmer as I normally store my
dates as datetime type in the format:

2005-07-08 10:52:44

What Is The Proper Date Format For A Txt Database?
I would like to know what format should be used when writing to a txt file. I am trying to search between a start date and a ending date and list any variables For example.

if (($sDate <= $jdate && $eDate >= $jdate))

then I have it list the variables it will work if searching between months and days but it does not work if I have different years. I will get all years printed out.

my date format is m/d/Y 6/13/2001

If I search for example start date = 6/01/2001 and the ending date = 6/09/2001

I will get the correct month and day dates but I also get anything from the year before and including year in the future.

Date Format When Inserting Data
I am getting a date entry through POST by a form byt the format enetered by the user is 'dd/mm/yy' .... how could i use MYSQL PHP syntax to insert the proper format as it is default in the table in my database. which function is it?

PHP Date Conversion To Readable Format
i have FPDF (php script that generates pdf files from variables). I can get the from date and to date to show, but they show like this: e.g.: 2006-12-20
now im trying to do this but its not working: Code:

Date & Time Format In Database.
I'm using MySQL database, the problem is I've setup that user input the Date format in dd/mm/yyyy (example: 14may2007) and Time (example: 12:00pm). How do I convert it to Date & Time format in database format before insert into database? Sorry, noob here.

Date Format In Join Statement?
$get_matches=mysql_query("SELECT matches.match_id, matches.game, matches.opponent, matches.map, DATE_FORMAT(`matches.date`, '%d/%c/%y') AS 'matches.date', matches.time, players.player_id, players.match_id FROM matches, players WHERE matches.match_id = players.match_id AND players.player_id='$player_id' AND matches.game='$game'") OR die(' ERROR GETTING TOTAL $game MATCHES ' . mysql_error());

Basically I'm trying to format a date column from the american style date format into the european one, but for some reason its not working. I've got it working in non join statements but I don't know how to do it in a join statement.

Date Format / Timestamp Problem
I am facing one problem in php, mysql whenever i submit empty date to db, it automatically takes timestamp as 943900200 ('30-11-1999') which is creating problems in my application..... currently handling this problem by hard coding timestamp validation.

Dates And European Date Format
ATM my database is using an American style date format with the year coming first, then the month then the day, is there a way to set it so it goes day, month, year?

Basically how it works is I got 3 drop down boxes with days, months and years in it. The user choose the desired date clicks a button and it updates the db. My problem is its has that American format and if I put it as text then I won't be able to do calculations or sorts on the date so I need it as a date.

Also do I need to actually change anything in my mysql data base in regards to the date field atm I got it set as a date is there any additional things I gotta change?

Output Format For A Timestamp Date Variable
I have a variable - $lastdate - that is the latest date any record in a
MySQL database was updated. Its MySQL format is TIMESTAMP.

If I say [echo $lastdate] I get the output I'd expect - 20060424221549
which is a YYYYMMDDHHMMSS format.

I'd like to be able to display that using a format of mm/dd/yy with no
leading spaces on the month and day. I don't know what the php command
is to do this. In other words, I'm trying to display a variable -
$lastdate - formatted a certain way. I know that the formatting string
n/j/y will get my output looking as I'd like, but I can't figure out how
to apply that to my variable.

Preg_match() Error, Match Only Valid Date In Mm/dd Format.
I am trying to create a function that will match only valid date in mm/
dd format. (Month in, 01, 02, ..., 09, 10, 11, 12 and Dates in 01,
02, ..., 11, 12, ..., 30, 31).

I am trying this code, but it fails to work.

The error is :-
PHP Warning: preg_match(): Compilation failed: unmatched parentheses
at offset 15 in /home/wizard/regexDateTime.php on line xx

The code is here.


Copyright © 2005-08 www.BigResource.com, All rights reserved