The datetime in salesforce is always stored in GMT (UTC). The time is corrected to the users time zone when displaying it on the UI. The time is only corrected in the UI, so you need to make the adjustment yourself for formula fields.
Datetime input field cast to another timezone
http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_select_dateformats.htm
You need to adjust for your own time zone in your formula to account for this. In my formula fields, since I am in EST, I have to adjust all the datetimes by 5 hours to make sure I have the correct values. I just do this in a long case statement like below. this formula finds the hour of the day that a case was created, notice I have to adjust each time by 5 hours to make it work
TEXT(CASE(VALUE(LEFT(RIGHT(text(CreatedDate),FIND(" ", TEXT( CreatedDate ))-2),2)),
00,19,
01,20,
02,21,
03,22,
04,23,
05,00,
06,01,
07,02,
08,03,
09,04,
10,05,
11,06,
12,07,
13,08,
14,09,
15,10,
16,11,
17,12,
18,13,
19,14,
20,15,
21,16,
22,17,
23,18,
00))
You can use the format
method of the DateTime Class. It outputs the date in the desired format.
Example:
System.now().format('yyyy-MM-dd')
Optionally, for you example, you can compare actual DateTimes without converting to string
System.assertEquals(DateTime.newInstance(System.today(), Time.newInstance(23, 0, 0 , 0)), ct.NextFireTime);
Best Answer
Date types are intrinsically DateTime types with the time factor set to 00:00:00. You can't have a Date that does not have a time factor. What you're asking for is impossible.