Jump to content

date functions


snorky

Recommended Posts

The goal is simple: I want to display "August 31, 2009"

 

I RTFMed and tried various date functions. I got inconsistent results, so I did some "sanity check"  tests. The results were better, but not completely as expected.

 

Some returned

Tuesday, August 18, 2009 15:08:45

 

Others returned

Wednesday, December 31, 2008 00:12:01

 

<?php			//	php 5.2

	$rightnow=$_SERVER['REQUEST_TIME'];

	$fmt= "l, F d, Y H:m:s";

	//	V
	$thev = mktime(0,0,1,08,31,2009);		
	$dayv = date($fmt,$thev);
               // returned [b]Wednesday, December 31, 2008 00:12:01[/b]

	//	W
	$thew = time(00,00,01,08,31,2009);		
	$dayw = date($fmt,$thew);
               // returned [b]Tuesday, August 18, 2009 15:08:17[/b] (current time)

	//	X
	$thex = time();		
	$dayx = date($fmt,$thex);
               // returned [b]Tuesday, August 18, 2009 15:08:17[/b] -- as expected

	//	Y
	$dayy = date($fmt,$rightnow);
               // returned [b]Wednesday, December 31, 1969 16:12:00[/b] (!!!)

	//	Z
	$dayz = date($fmt);
               // returned [b]Tuesday, August 18, 2009 15:08:17[/b] -- as expected

?>

 

What is the correct syntax to display August 31,2009

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.